Mercurial > emacs
annotate lisp/net/newsticker.el @ 85487:8dd3c37f1eb5
*** empty log message ***
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Sat, 20 Oct 2007 15:38:24 +0000 |
parents | 60f8467b3790 |
children | 6888fd3398e8 2ca0af23d79d f55f9811f5d7 |
rev | line source |
---|---|
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
1 ;;; newsticker.el --- A Newsticker for Emacs. |
65468 | 2 |
75347 | 3 ;; Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. |
65468 | 4 |
5 ;; This file is part of GNU Emacs. | |
6 | |
7 ;; Author: Ulf Jasper <ulf.jasper@web.de> | |
8 ;; Filename: newsticker.el | |
9 ;; URL: http://www.nongnu.org/newsticker | |
10 ;; Created: 17. June 2003 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
11 ;; Keywords: News, RSS, Atom |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
12 ;; Time-stamp: "29. Januar 2007, 21:05:09 (ulf)" |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
13 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
14 ;; ====================================================================== |
65468 | 15 |
78229
60f8467b3790
Standardize license wording, and switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
75838
diff
changeset
|
16 ;; GNU Emacs is free software; you can redistribute it and/or modify |
65468 | 17 ;; it under the terms of the GNU General Public License as published by |
78229
60f8467b3790
Standardize license wording, and switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
75838
diff
changeset
|
18 ;; the Free Software Foundation; either version 3, or (at your option) |
60f8467b3790
Standardize license wording, and switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
75838
diff
changeset
|
19 ;; any later version. |
65468 | 20 |
21 ;; This program is distributed in the hope that it will be useful, but | |
22 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
24 ;; General Public License for more details. | |
25 | |
26 ;; You should have received a copy of the GNU General Public License | |
78229
60f8467b3790
Standardize license wording, and switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
75838
diff
changeset
|
27 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
60f8467b3790
Standardize license wording, and switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
75838
diff
changeset
|
28 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
60f8467b3790
Standardize license wording, and switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
75838
diff
changeset
|
29 ;; Boston, MA 02110-1301, USA. |
65468 | 30 |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
31 (defconst newsticker-version "1.10" "Version number of newsticker.el.") |
65998
e6b90c8b34d8
(newsticker-start, newsticker-show-news): Add autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents:
65638
diff
changeset
|
32 |
65468 | 33 ;; ====================================================================== |
34 ;;; Commentary: | |
35 | |
36 ;; Overview | |
37 ;; -------- | |
38 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
39 ;; Newsticker provides a newsticker for Emacs. A newsticker is a thing |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
40 ;; that asynchronously retrieves headlines from a list of news sites, |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
41 ;; prepares these headlines for reading, and allows for loading the |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
42 ;; corresponding articles in a web browser. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
43 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
44 ;; Headlines consist of a title and (possibly) a small description. They |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
45 ;; are contained in "RSS" (RDF Site Summary) or "Atom" files. Newsticker |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
46 ;; should work with the following RSS formats: |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
47 ;; * RSS 0.91 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
48 ;; (see http://backend.userland.com/rss091 or |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
49 ;; http://my.netscape.com/publish/formats/rss-spec-0.91.html) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
50 ;; * RSS 0.92 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
51 ;; (see http://backend.userland.com/rss092) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
52 ;; * RSS 1.0 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
53 ;; (see http://purl.org/rss/1.0/spec) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
54 ;; * RSS 2.0 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
55 ;; (see http://blogs.law.harvard.edu/tech/rss) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
56 ;; as well as the following Atom formats: |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
57 ;; * Atom 0.3 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
58 ;; * Atom 1.0 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
59 ;; (see http://www.ietf.org/internet-drafts/draft-ietf-atompub-format-11.txt) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
60 ;; That makes Newsticker.el an "Atom aggregator, "RSS reader", "RSS |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
61 ;; aggregator", and "Feed Reader". |
65468 | 62 |
63 ;; Newsticker provides several commands for reading headlines, navigating | |
64 ;; through them, marking them as read/unread, hiding old headlines | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
65 ;; etc. Headlines can be displayed as plain text or as rendered HTML. |
65468 | 66 |
67 ;; Headlines can be displayed in the echo area, either scrolling like | |
68 ;; messages in a stock-quote ticker, or just changing. | |
69 | |
70 ;; Newsticker allows for automatic processing of headlines by providing | |
71 ;; hooks and (sample) functions for automatically downloading images and | |
72 ;; enclosed files (as delivered by podcasts, e.g.). | |
73 | |
74 ;; Requirements | |
75 ;; ------------ | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
76 ;; Newsticker can be used with GNU Emacs version 21.1 or later as well as |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
77 ;; XEmacs. It requires an XML-parser (`xml.el') which is part of GNU |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
78 ;; Emacs. If you are using XEmacs you want to get the `net-utils' package |
65468 | 79 ;; which contains `xml.el' for XEmacs. |
80 | |
81 ;; Newsticker requires a program which can retrieve files via http and | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
82 ;; prints them to stdout. By default Newsticker will use wget for this |
65468 | 83 ;; task. |
84 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
85 ;; Installation |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
86 ;; ------------ |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
87 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
88 ;; If you are using Newsticker as part of GNU Emacs there is no need to |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
89 ;; perform any installation steps in order to use Newsticker. Otherwise |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
90 ;; place Newsticker in a directory where Emacs can find it. Add the |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
91 ;; following line to your Emacs startup file (`~/.emacs'). |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
92 ;; (add-to-list 'load-path "/path/to/newsticker/") |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
93 ;; (autoload 'newsticker-start "newsticker" "Emacs Newsticker" t) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
94 ;; (autoload 'newsticker-show-news "newsticker" "Emacs Newsticker" t) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
95 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
96 ;; If you are using `imenu', which allows for navigating with the help of a |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
97 ;; menu, you should add the following to your Emacs startup file |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
98 ;; (`~/.emacs'). |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
99 ;; (add-hook 'newsticker-mode-hook 'imenu-add-menubar-index) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
100 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
101 ;; That's it. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
102 |
65468 | 103 ;; Usage |
104 ;; ----- | |
105 ;; The command newsticker-show-news will display all available headlines in | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
106 ;; a special buffer, called `*newsticker*'. It will also start the |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
107 ;; asynchronous download of headlines. The modeline in the `*newsticker*' |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
108 ;; buffer informs whenever new headlines have arrived. Clicking |
65468 | 109 ;; mouse-button 2 or pressing RET in this buffer on a headline will call |
110 ;; browse-url to load the corresponding news story in your favourite web | |
111 ;; browser. | |
112 | |
113 ;; The scrolling, or flashing of headlines in the echo area, can be started | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
114 ;; with the command newsticker-start-ticker. It can be stopped with |
65468 | 115 ;; newsticker-stop-ticker. |
116 | |
117 ;; If you just want to start the periodic download of headlines use the | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
118 ;; command newsticker-start. Calling newsticker-stop will stop the |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
119 ;; periodic download, but will call newsticker-stop-ticker as well. |
65468 | 120 |
121 ;; Configuration | |
122 ;; ------------- | |
123 ;; All Newsticker options are customizable, i.e. they can be changed with | |
124 ;; Emacs customization methods: Call the command customize-group and enter | |
125 ;; `newsticker' for the customization group. | |
126 | |
127 ;; All Newsticker options have reasonable default values, so that in most | |
128 ;; cases it is not necessary to customize settings before starting | |
129 ;; Newsticker for the first time. | |
130 | |
131 ;; Newsticker options are organized in the following groups. | |
132 | |
133 ;; * newsticker-feed contains options that define which news | |
134 ;; feeds are retrieved and how this is done. | |
135 ;; o newsticker-url-list defines the list of headlines which are | |
136 ;; retrieved. | |
137 ;; o newsticker-retrieval-interval defines how often headlines are | |
138 ;; retrieved. | |
139 ;; * newsticker-headline-processing contains options that define how the | |
140 ;; retrieved headlines are processed. | |
141 ;; o newsticker-keep-obsolete-items decides whether unread headlines that | |
142 ;; have been removed from the feed are kept in the Newsticker cache. | |
143 ;; * newsticker-layout contains options that define how the buffer for | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
144 ;; reading news headlines is formatted. |
65468 | 145 ;; o newsticker-item-format defines how the title of a headline is |
146 ;; formatted. | |
147 ;; * newsticker-ticker contains options that define how headlines are shown | |
148 ;; in the echo area. | |
149 ;; o newsticker-display-interval and newsticker-scroll-smoothly define | |
150 ;; how headlines are shown in the echo area. | |
151 ;; * newsticker-hooks contains options for hooking other Emacs commands to | |
152 ;; newsticker functions. | |
153 ;; o newsticker-new-item-functions allows for automatic processing of | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
154 ;; headlines. See `newsticker-download-images', and |
65468 | 155 ;; `newsticker-download-enclosures' for sample functions. |
156 ;; * newsticker-miscellaneous contains other Newsticker options. | |
157 | |
158 ;; Please have a look at the customization buffers for the complete list of | |
159 ;; options. | |
160 | |
161 ;; Remarks | |
162 ;; ------- | |
163 ;; This newsticker is designed do its job silently in the background | |
164 ;; without disturbing you. However, it is probably impossible to prevent | |
165 ;; such a tool from slightly attenuating your Editor's responsiveness every | |
166 ;; once in a while. | |
167 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
168 ;; Byte-compiling newsticker.el is recommended. |
65468 | 169 |
170 ;; ====================================================================== | |
171 ;;; History: | |
172 | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
173 ;; 1.10 (2007-01-29) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
174 ;; * Bugfixes mostly: `newsticker--decode-iso8601-date', |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
175 ;; `newsticker--sentinel', and others. |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
176 ;; * Renamed `newsticker--retrieval-timer-list' to |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
177 ;; `newsticker-retrieval-timer-list'. Removed |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
178 ;; `newsticker-running-p' -- check newsticker-retrieval-timer-list |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
179 ;; to find out whether newsticker is running. Removed |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
180 ;; `newsticker-ticker-running-p'. |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
181 ;; * Try to cache images in w3m-rendered HTML text. |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
182 ;; * Other minor changes. |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
183 |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
184 ;; 1.9 (2005-11-01) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
185 ;; * Rewrote feed parsing part. Newsticker now supports RSS 0.91, |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
186 ;; 0.92, 1.0, 2.0 as well as Atom 0.3 and 1.0 -- thanks to Thien-Thi |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
187 ;; Nguyen. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
188 ;; * Changed auto-marking mechanism: Replaced variable |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
189 ;; `newsticker-auto-mark-filter' with new variable |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
190 ;; `newsticker-auto-mark-filter-list', which allows for looking not |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
191 ;; only at the title but also at the description of a headline. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
192 ;; * Call `newsticker--ticker-text-setup' only after all pending |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
193 ;; downloads processes have finished. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
194 ;; * Improved handling of coding systems. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
195 ;; * Added magic autoload comments. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
196 ;; * Bugfixes: |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
197 ;; - `hide-entry' was hiding too much when called for the last |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
198 ;; headline, |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
199 ;; - update mode-line and menu-bar when necessary, |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
200 ;; - repaired `newsticker--imenu-goto', |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
201 ;; - other minor things. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
202 |
65468 | 203 ;; 1.8 (2005-08-26) |
204 ;; * Added commands `newsticker-show-extra' and `newsticker-hide-extra' | |
205 ;; to show and hide extra RSS elements, bound to "sx" and "hx" | |
206 ;; resp. Changed default value of `newsticker-show-all-rss-elements' | |
207 ;; to nil. | |
208 ;; * mode-line: Introduced special mode-line-format for newsticker. | |
209 ;; * Get feed logos only once every 24 h. | |
210 ;; * Default faces changed. | |
211 ;; * Minor fixes. | |
212 | |
213 ;; 1.7 (2005-06-25) | |
214 ;; * Tool-bar support: most important commands can be called from | |
215 ;; tool-bar buttons. | |
216 ;; * Auto-Narrowing introduced: *newsticker* buffer can be narrowed to | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
217 ;; a single item (bound to key `xi') or a single feed (bound to |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
218 ;; `xf'). |
65468 | 219 ;; * Enclosure support: enclosed items are shown (see |
220 ;; `newsticker-enclosure-face') and can be (automatically) downloaded | |
221 ;; (see below). For those of you who read "podcasts". | |
222 ;; * Added variable `newsticker-auto-mark-filter' for automatically | |
223 ;; marking items as immortal or old. | |
224 ;; * Added hook variable `newsticker-new-item-functions' for handling | |
225 ;; new items. Added sample functions `newsticker-download-images', | |
226 ;; and `newsticker-download-enclosures'. | |
227 ;; * Added hook variable `newsticker-select-item-hook' which is run | |
228 ;; after `newsticker-(next|previous)-(new-)?-item'. | |
229 ;; * Added hook variable `newsticker-select-feed-hook' which is run | |
230 ;; after `newsticker-(next|previous)-feed'. | |
231 ;; * Added hook variable `newsticker-buffer-change-hook' which is run | |
232 ;; after the contents or visibility of the newsticker buffer has | |
233 ;; changed, e.g. after `newsticker-buffer-update' or | |
234 ;; `newsticker-show-feed-desc'. | |
235 ;; * Added command `newsticker-handle-url' for interactively launching | |
236 ;; arbitrary programs for URLs, bound to `C-RET'. | |
237 ;; * URLs in extra elements are clickable. | |
238 ;; * Better support for w3, added command | |
239 ;; `newsticker-w3m-show-inline-images' for displaying all inline | |
240 ;; images. | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
241 ;; * Insert an artificial headline which notifies about failed |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
242 ;; retrievals. |
65468 | 243 ;; * Use pubDate element (RSS 2.0) instead of retrieval time when |
244 ;; available. | |
245 ;; * Customizable options grouped. | |
246 ;; * Bugfixes: `newsticker--imenu-create-index'; strip whitespace | |
247 ;; from links; apply coding-system to extra-elements; time-comparison | |
248 ;; for obsolete items; and others which I have forgotten. | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
249 ;; * Workaround for another bug in xml-parse-region -- thanks to |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
250 ;; anonymous for sending patch. |
65468 | 251 ;; * Renamed invisible buffers ` *wget-newsticker-<feed>*' to |
252 ;; ` *newsticker-wget-<feed>*'. | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
253 ;; * Tested with GNU Emacs versions 21.3 and 22.0 and XEmacs |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
254 ;; 21.something. |
65468 | 255 |
256 ;; 1.6 * Support for (some) optional RSS elements: guid, dc:date. See | |
257 ;; `newsticker-show-all-rss-elements' `newsticker-extra-face'. | |
258 ;; * Better support for w3m -- `newsticker-default-face' is obsolete | |
259 ;; now, removed `newsticker-w3m-toggle-inline-image'. | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
260 ;; * Added `newsticker-desc-comp-max' -- comparison of item |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
261 ;; descriptions can take quite some time. |
65468 | 262 ;; * Added `newsticker--buffer-make-item-completely-visible' to |
263 ;; ensure that the current item is fully visible. | |
264 ;; * Allow for non-positive retrieval-interval, which make newsticker | |
265 ;; get news only once. | |
266 ;; * Use :set for customizable variables. | |
267 ;; * Added `newsticker-buffer-force-update', bound to key `U'. | |
268 ;; * Added concept of obsolete items, see | |
269 ;; `newsticker-keep-obsolete-items', `newsticker-obsolete-item-face', | |
270 ;; `newsticker-obsolete-item-max-age'. | |
271 ;; * Added `newsticker-add-url'. | |
272 ;; * OPML export. | |
273 ;; * Save pre-formatted titles => even better performance!! | |
274 ;; * `newsticker-*-new-item' wraps at beginning/end of buffer. | |
275 ;; * Always sort obsolete items to end of item list. | |
276 ;; * Bugfixes: | |
277 ;; - newsticker-hide-entry, | |
278 ;; - changes of feed-titles led to duplicate feed items, | |
279 ;; - faces for rendered HTML texts, | |
280 ;; - length of ticker-text (for "exotic"/multibyte texts), | |
281 ;; Thanks to Hiroshi Maruyama. | |
282 ;; - suppress items with empty title and description | |
283 ;; - newsticker-sort-method was ignored! | |
284 ;; - prevent call of fill-region on HTML-rendered descriptions. | |
285 | |
286 ;; 1.5 * Rewrote the visibility stuff. newsticker does not inherit | |
287 ;; outline anymore. Now you have complete freedom for | |
288 ;; `newsticker-*-format'. | |
289 ;; * Save pre-formatted descriptions => incredible performance boost!! | |
290 ;; * Introduced `newsticker-(start|stop)-ticker'. | |
291 ;; * Introduced statistics for heading-format and | |
292 ;; `newsticker-statistics-face'. | |
293 ;; * Introduced `newsticker-enable-logo-manipulations'. | |
294 ;; * Compare link of items (as well as title and desc). | |
295 ;; * Added `newsticker-start-hook' and `newsticker-stop-hook', thanks | |
296 ;; to mace. | |
297 ;; * Bugfixes -- thanks to Ryan Yeske, Jari Aalto, Bruce Ingalls. | |
298 ;; * Tested with Emacs 21.3.50, 21.3.1, 21.2, 21.1; XEmacs 21.4.15 | |
299 | |
300 ;; 1.4 * Enabled HTML rendering, added `newsticker-html-renderer' to | |
301 ;; choose a HTML rendering engine, thanks to Greg Scott for testing | |
302 ;; * New Outline handling using text properties instead of "**" | |
303 ;; prefixes. | |
304 ;; * Added possibility to mark single item as old (bound to key | |
305 ;; `o' (`newsticker-mark-item-at-point-as-read'). | |
306 ;; * Added possibility to mark single item as immortal (bound to key | |
307 ;; `i' (`newsticker-mark-item-at-point-as-immortal'). | |
308 ;; * Added possibility to display feed logos. | |
309 ;; * Added `newsticker-heading-format', `newsticker-item-format'. | |
310 ;; * Added `newsticker-date-format'. | |
311 ;; * Added `newsticker-justification'. | |
312 ;; * Added `newsticker-automatically-mark-visited-items-as-old'. | |
313 ;; * Added `newsticker-w3m-toggle-inline-image' which calls | |
314 ;; `w3m-toggle-inline-image' if `newsticker-html-renderer' is | |
315 ;; `w3m-region'. Exists for convenience only (bound to key | |
316 ;; `RET'). | |
317 | |
318 ;; 1.3 * Compare title AND desc to check whether item is old, except | |
319 ;; for feed desc | |
320 ;; * Mark as not-up-to-date only after new items have arrived. | |
321 ;; * Added XEmacs compatibility code, tested with XEmacs 21.4.13. | |
322 ;; * Tested with Emacs 21.3.50 and Emacs 21.2.something. | |
323 ;; * Bugfix: Apply coding-systems to feed title and description, | |
324 ;; thanks to OHASHI Akira | |
325 ;; * Bugfix: xml-parser-workaround did not work for japanese texts, | |
326 ;; thanks to OHASHI Akira | |
327 ;; * Kill wget-buffers unless newsticker-debug is not nil. | |
328 ;; * Bugfix: xml-parser-workaround for "DOCTYPE rdf:RDF" | |
329 | |
330 ;; 1.2 Peter S Galbraith <psg@debian.org> | |
331 ;; * Added `newsticker-url-list-defaults', splitting the URLs into | |
332 ;; a customizable selection list, and a user add-on list. | |
333 ;; * Minor checkdoc fixes. | |
334 | |
335 ;; 1.1 * Introduced optional feed-specific wget-arguments. | |
336 ;; * Keep order of feeds as given in `newsticker-url-list' in | |
337 ;; *newsticker* buffer. | |
338 ;; * Ignore unsupported coding systems. | |
339 | |
340 ;; 1.0 * Introduced feed-specific retrieval-timers. | |
341 ;; * Removed dependency on 'cl (cddddr). | |
342 ;; * Thanks to Kevin Rodgers and T.V. Raman for their help. | |
343 ;; * Use utf-8 for reading and writing cache data. | |
344 ;; * Reported to work with Emacs 21.3.50. | |
345 | |
346 ;; 0.99 * Minor tweaks. | |
347 ;; * Tested with Emacs 21.3.2 | |
348 | |
349 ;; 0.98 * Check exit status of wget processes. Keep cache data if | |
350 ;; something went wrong. Throw error when old wget-processes | |
351 ;; are hanging around. | |
352 ;; * Introduced newsticker-specific faces. | |
353 ;; * Added `newsticker-show-descriptions-of-new-items'. | |
354 ;; * Added `newsticker-hide-old-items-in-newsticker-buffer'. | |
355 ;; * Added `newsticker-(hide|show)-old-items'. | |
356 | |
357 ;; 0.97 * Minor tweaks. | |
358 | |
359 ;; 0.96 * Added caching. | |
360 ;; * newsticker-mode inherits outline-mode. | |
361 ;; * newsticker-mode supports imenu. | |
362 ;; * Easy buffer-navigation with newsticker-mode's keymap. | |
363 ;; * Some bugs fixed. | |
364 ;; * Thanks to Moritz Epple for documentation tips. | |
365 | |
366 ;; 0.95 * Added newsticker-mode -- Thanks to T.V. Raman. | |
367 ;; * Catch xml-parser errors -- Thanks to T.V. Raman. | |
368 ;; * Remove stupid newlines in titles (headlines) -- Thanks to | |
369 ;; Jeff Rancier. | |
370 | |
371 ;; 0.94 * Added clickerability and description for channel headings. | |
372 ;; * Made it work for (at least some) rss 0.9<something> feeds. | |
373 | |
374 ;; 0.93 * Added some more sites. | |
375 ;; * Do not flood the *Messages* buffer. | |
376 ;; * First attempt at handling coding systems. | |
377 | |
378 ;; 0.92 * Added `newsticker-wget-name'. | |
379 ;; * Try to display message only if minibuffer and echo area are | |
380 ;; not in use already. | |
381 ;; * Dirty workaround for newer versions of xml.el: Remove | |
382 ;; whitespace in rdf. | |
383 ;; * Tested with Emacs 21.3.2 and CVS-snapshot of 2003-06-21. | |
384 | |
385 ;; 0.91 * First bugfix: *newsticker* is read-only. | |
386 | |
387 ;; 0.9 * First release. | |
388 ;; * Tested with Emacs 21.3.2 and wget 1.8.2. | |
389 | |
390 ;; ====================================================================== | |
391 ;;; To Do: | |
392 | |
393 ;; * Image handling for XEmacs (create-image does not exist) | |
394 | |
395 ;; ====================================================================== | |
396 ;;; Code: | |
397 | |
398 (require 'derived) | |
399 (require 'xml) | |
400 | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
401 ;; Silence warnings |
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
402 (defvar tool-bar-map) |
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
403 (defvar w3-mode-map) |
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
404 (defvar w3m-minor-mode-map) |
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
405 |
65468 | 406 ;; ====================================================================== |
67593
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
407 ;;; Newsticker status |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
408 ;; ====================================================================== |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
409 |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
410 (defvar newsticker--retrieval-timer-list nil |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
411 "List of timers for news retrieval. |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
412 This is an alist, each element consisting of (feed-name . timer).") |
67593
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
413 |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
414 (defvar newsticker--display-timer nil |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
415 "Timer for newsticker display.") |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
416 |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
417 ;;;###autoload |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
418 (defun newsticker-running-p () |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
419 "Check whether newsticker is running. |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
420 Return t if newsticker is running, nil otherwise. Newsticker is |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
421 considered to be running if the newsticker timer list is not empty." |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
422 (> (length newsticker--retrieval-timer-list) 0)) |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
423 |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
424 ;;;###autoload |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
425 (defun newsticker-ticker-running-p () |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
426 "Check whether newsticker's actual ticker is running. |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
427 Return t if ticker is running, nil otherwise. Newsticker is |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
428 considered to be running if the newsticker timer list is not |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
429 empty." |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
430 (timerp newsticker--display-timer)) |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
431 |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
432 ;; ====================================================================== |
65468 | 433 ;;; Customizables |
434 ;; ====================================================================== | |
435 (defgroup newsticker nil | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
436 "Aggregator for RSS and Atom feeds." |
65468 | 437 :group 'applications) |
438 | |
439 (defconst newsticker--raw-url-list-defaults | |
440 '(("CNET News.com" | |
441 "http://export.cnet.com/export/feeds/news/rss/1,11176,,00.xml") | |
442 ("Debian Security Advisories" | |
443 "http://www.debian.org/security/dsa.en.rdf") | |
444 ("Debian Security Advisories - Long format" | |
445 "http://www.debian.org/security/dsa-long.en.rdf") | |
446 ("Emacs Wiki" | |
447 "http://www.emacswiki.org/cgi-bin/wiki.pl?action=rss" | |
448 nil | |
449 3600) | |
450 ("Freshmeat.net" | |
451 "http://freshmeat.net/backend/fm.rdf") | |
452 ("Kuro5hin.org" | |
453 "http://www.kuro5hin.org/backend.rdf") | |
454 ("LWN (Linux Weekly News)" | |
455 "http://lwn.net/headlines/rss") | |
456 ("NewsForge" | |
457 "http://newsforge.com/index.rss") | |
458 ("NY Times: Technology" | |
459 "http://partners.userland.com/nytRss/technology.xml") | |
460 ("NY Times" | |
461 "http://partners.userland.com/nytRss/nytHomepage.xml") | |
462 ("Quote of the day" | |
463 "http://www.quotationspage.com/data/qotd.rss" | |
464 "07:00" | |
465 86400) | |
466 ("The Register" | |
467 "http://www.theregister.co.uk/tonys/slashdot.rdf") | |
468 ("slashdot" | |
469 "http://slashdot.org/index.rss" | |
470 nil | |
471 3600) ;/. will ban you if under 3600 seconds! | |
472 ("Wired News" | |
473 "http://www.wired.com/news_drop/netcenter/netcenter.rdf") | |
474 ("Heise News (german)" | |
475 "http://www.heise.de/newsticker/heise.rdf") | |
476 ("Tagesschau (german)" | |
477 "http://www.tagesschau.de/newsticker.rdf" | |
478 nil | |
479 1800) | |
480 ("Telepolis (german)" | |
481 "http://www.heise.de/tp/news.rdf")) | |
482 "Default URL list in raw form. | |
483 This list is fed into defcustom via `newsticker--splicer'.") | |
484 | |
485 (defun newsticker--splicer (item) | |
486 "Convert ITEM for splicing into `newsticker-url-list-defaults'." | |
487 (let ((result (list 'list :tag (nth 0 item) (list 'const (nth 0 item)))) | |
488 (element (cdr item))) | |
489 (while element | |
490 (setq result (append result (list (list 'const (car element))))) | |
491 (setq element (cdr element))) | |
492 result)) | |
493 | |
494 ;; ====================================================================== | |
495 ;;; Customization | |
496 ;; ====================================================================== | |
497 (defun newsticker--set-customvar (symbol value) | |
498 "Set newsticker-variable SYMBOL value to VALUE. | |
499 | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
500 Calls all necessary actions which are necessary in order to make |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
501 the new value effective. Changing `newsticker-url-list', for example, |
65468 | 502 will re-start the retrieval-timers." |
503 (unless (condition-case nil | |
504 (eq (symbol-value symbol) value) | |
505 (error nil)) | |
506 (set symbol value) | |
507 (cond ((eq symbol 'newsticker-sort-method) | |
508 (when (fboundp 'newsticker--cache-sort) | |
509 (message "Applying new sort method...") | |
510 (newsticker--cache-sort) | |
511 (newsticker--buffer-set-uptodate nil) | |
512 (message "Applying new sort method...done"))) | |
513 ((memq symbol '(newsticker-url-list-defaults | |
514 newsticker-url-list | |
515 newsticker-retrieval-interval)) | |
516 (when (and (fboundp 'newsticker-running-p) | |
517 (newsticker-running-p)) | |
518 (message "Restarting newsticker") | |
519 (newsticker-stop) | |
520 (newsticker-start))) | |
521 ((eq symbol 'newsticker-display-interval) | |
522 (when (and (fboundp 'newsticker-running-p) | |
523 (newsticker-running-p)) | |
524 (message "Restarting ticker") | |
525 (newsticker-stop-ticker) | |
526 (newsticker-start-ticker) | |
527 (message ""))) | |
528 ((memq symbol '(newsticker-hide-old-items-in-echo-area | |
529 newsticker-hide-obsolete-items-in-echo-area | |
530 newsticker-hide-immortal-items-in-echo-area)) | |
531 (when (and (fboundp 'newsticker-running-p) | |
532 (newsticker-running-p)) | |
533 (message "Restarting newsticker") | |
534 (newsticker-stop-ticker) | |
535 (newsticker--ticker-text-setup) | |
536 (newsticker-start-ticker) | |
537 (message ""))) | |
538 ((memq symbol '(newsticker-hide-old-items-in-newsticker-buffer | |
539 newsticker-show-descriptions-of-new-items)) | |
540 (when (fboundp 'newsticker--buffer-set-uptodate) | |
541 (newsticker--buffer-set-uptodate nil))) | |
542 ((memq symbol '(newsticker-heading-format | |
543 newsticker-item-format | |
544 newsticker-desc-format | |
545 newsticker-date-format | |
546 newsticker-statistics-format | |
547 newsticker-justification | |
548 newsticker-use-full-width | |
549 newsticker-html-renderer | |
550 newsticker-feed-face | |
551 newsticker-new-item-face | |
552 newsticker-old-item-face | |
553 newsticker-immortal-item-face | |
554 newsticker-obsolete-item-face | |
555 newsticker-date-face | |
556 newsticker-statistics-face | |
557 ;;newsticker-default-face | |
558 )) | |
559 (when (fboundp 'newsticker--forget-preformatted) | |
560 (newsticker--forget-preformatted))) | |
561 (t | |
562 (error "Ooops %s" symbol))))) | |
563 | |
564 ;; customization group feed | |
565 (defgroup newsticker-feed nil | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
566 "Settings for news feeds." |
65468 | 567 :group 'newsticker) |
568 | |
569 (defcustom newsticker-url-list-defaults | |
570 '(("Emacs Wiki" | |
571 "http://www.emacswiki.org/cgi-bin/wiki.pl?action=rss" | |
572 nil | |
573 3600)) | |
574 "A customizable list of news feeds to select from. | |
575 These were mostly extracted from the Radio Community Server at | |
576 http://subhonker6.userland.com/rcsPublic/rssHotlist. | |
577 | |
578 You may add other entries in `newsticker-url-list'." | |
579 :type `(set ,@(mapcar `newsticker--splicer | |
580 newsticker--raw-url-list-defaults)) | |
581 :set 'newsticker--set-customvar | |
582 :group 'newsticker-feed) | |
583 | |
584 (defcustom newsticker-url-list nil | |
585 "The news feeds which you like to watch. | |
586 | |
587 This alist will be used in addition to selection made customizing | |
588 `newsticker-url-list-defaults'. | |
589 | |
590 This is an alist. Each element consists of two items: a LABEL and a URL, | |
591 optionally followed by a START-TIME, INTERVAL specifier and WGET-ARGUMENTS. | |
592 | |
593 The LABEL gives the name of the news feed. It can be an arbitrary string. | |
594 | |
595 The URL gives the location of the news feed. It must point to a valid | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
596 RSS or Atom file. The file is retrieved by calling wget, or whatever you |
65468 | 597 specify as `newsticker-wget-name'. |
598 | |
599 The START-TIME can be either a string, or nil. If it is a string it | |
600 specifies a fixed time at which this feed shall be retrieved for the | |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
601 first time. (Examples: \"11:00pm\", \"23:00\".) If it is nil (or |
65468 | 602 unspecified), this feed will be retrieved immediately after calling |
603 `newsticker-start'. | |
604 | |
605 The INTERVAL specifies the time between retrievals for this feed. If it | |
606 is nil (or unspecified) the default interval value as set in | |
607 `newsticker-retrieval-interval' is used. | |
608 | |
609 \(newsticker.el calls `run-at-time'. The newsticker-parameters START-TIME | |
610 and INTERVAL correspond to the `run-at-time'-parameters TIME and REPEAT.) | |
611 | |
612 WGET-ARGUMENTS specifies arguments for wget (see `newsticker-wget-name') | |
613 which apply for this feed only, overriding the value of | |
614 `newsticker-wget-arguments'." | |
615 :type '(repeat (list :tag "News feed" | |
616 (string :tag "Label") | |
617 (string :tag "URI") | |
618 (choice :tag "Start" | |
619 (const :tag "Default" nil) | |
620 (string :tag "Fixed Time")) | |
621 (choice :tag "Interval" | |
622 (const :tag "Default" nil) | |
623 (const :tag "Hourly" 3600) | |
624 (const :tag "Daily" 86400) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
625 (const :tag "Weekly" 604800) |
65468 | 626 (integer :tag "Interval")) |
627 (choice :tag "Wget Arguments" | |
628 (const :tag "Default arguments" nil) | |
629 (repeat :tag "Special arguments" string)))) | |
630 :set 'newsticker--set-customvar | |
631 :group 'newsticker-feed) | |
632 | |
633 (defcustom newsticker-wget-name | |
634 "wget" | |
635 "Name of the program which is called to retrieve news from the web. | |
636 The canonical choice is wget but you may take any other program which is | |
637 able to return the contents of a news feed file on stdout." | |
638 :type 'string | |
639 :group 'newsticker-feed) | |
640 | |
641 (defcustom newsticker-wget-arguments | |
642 '("-q" "-O" "-") | |
643 "Arguments which are passed to wget. | |
644 There is probably no reason to change the default settings, unless you | |
645 are living behind a firewall." | |
646 :type '(repeat (string :tag "Argument")) | |
647 :group 'newsticker-feed) | |
648 | |
649 (defcustom newsticker-retrieval-interval | |
650 3600 | |
651 "Time interval for retrieving new news items (seconds). | |
652 If this value is not positive (i.e. less than or equal to 0) | |
653 items are retrieved only once! | |
654 Please note that some feeds, e.g. Slashdot, will ban you if you | |
655 make it less than 1800 seconds (30 minutes)!" | |
656 :type '(choice :tag "Interval" | |
657 (const :tag "No automatic retrieval" 0) | |
658 (const :tag "Hourly" 3600) | |
659 (const :tag "Daily" 86400) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
660 (const :tag "Weekly" 604800) |
65468 | 661 (integer :tag "Interval")) |
662 :set 'newsticker--set-customvar | |
663 :group 'newsticker-feed) | |
664 | |
665 (defcustom newsticker-desc-comp-max | |
666 100 | |
667 "Relevant length of headline descriptions. | |
668 This value gives the maximum number of characters which will be | |
669 taken into account when newsticker compares two headline | |
670 descriptions." | |
671 :type 'integer | |
672 :group 'newsticker-feed) | |
673 | |
674 ;; customization group behaviour | |
675 (defgroup newsticker-headline-processing nil | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
676 "Settings for the automatic processing of headlines." |
65468 | 677 :group 'newsticker) |
678 | |
679 (defcustom newsticker-automatically-mark-items-as-old | |
680 t | |
681 "Decides whether to automatically mark items as old. | |
682 If t a new item is considered as new only after its first retrieval. As | |
683 soon as it is retrieved a second time, it becomes old. If not t all | |
684 items stay new until you mark them as old. This is done in the | |
685 *newsticker* buffer." | |
686 :type 'boolean | |
687 :group 'newsticker-headline-processing) | |
688 | |
689 (defcustom newsticker-automatically-mark-visited-items-as-old | |
690 t | |
691 "Decides whether to automatically mark visited items as old. | |
692 If t an item is marked as old as soon as the associated link is | |
693 visited, i.e. after pressing RET or mouse2 on the item's | |
694 headline." | |
695 | |
696 :type 'boolean | |
697 :group 'newsticker-headline-processing) | |
698 | |
699 (defcustom newsticker-keep-obsolete-items | |
700 t | |
701 "Decides whether to keep unread items which have been removed from feed. | |
702 If t a new item, which has been removed from the feed, is kept in | |
703 the cache until it is marked as read." | |
704 :type 'boolean | |
705 :group 'newsticker-headline-processing) | |
706 | |
707 (defcustom newsticker-obsolete-item-max-age | |
708 (* 60 60 24) | |
709 "Maximal age of obsolete items, in seconds. | |
710 Obsolete items which are older than this value will be silently | |
711 deleted at the next retrieval." | |
712 :type 'integer | |
713 :group 'newsticker-headline-processing) | |
714 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
715 (defcustom newsticker-auto-mark-filter-list |
65468 | 716 nil |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
717 "A list of filters for automatically marking headlines. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
718 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
719 This is an alist of the form (FEED-NAME PATTERN-LIST). I.e. each |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
720 element consists of a FEED-NAME a PATTERN-LIST. Each element of |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
721 the pattern-list has the form (AGE TITLE-OR-DESCRIPTION REGEXP). |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
722 AGE must be one of the symbols 'old or 'immortal. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
723 TITLE-OR-DESCRIPTION must be on of the symbols 'title, |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
724 'description, or 'all. REGEXP is a regular expression, i.e. a |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
725 string. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
726 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
727 This filter is checked after a new headline has been retrieved. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
728 If FEED-NAME matches the name of the corresponding news feed, the |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
729 pattern-list is checked: The new headline will be marked as AGE |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
730 if REGEXP matches the headline's TITLE-OR-DESCRIPTION. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
731 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
732 If, for example, `newsticker-auto-mark-filter-list' looks like |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
733 \((slashdot ('old 'title \"^Forget me!$\") ('immortal 'title \"Read me\") |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
734 \('immortal 'all \"important\")))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
735 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
736 then all articles from slashdot are marked as old if they have |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
737 the title \"Forget me!\". All articles with a title containing |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
738 the string \"Read me\" are marked as immortal. All articles which |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
739 contain the string \"important\" in their title or their |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
740 description are marked as immortal." |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
741 :type '(repeat (list :tag "Auto mark filter" |
65468 | 742 (string :tag "Feed name") |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
743 (repeat |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
744 (list :tag "Filter element" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
745 (choice |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
746 :tag "Auto-assigned age" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
747 (const :tag "Old" old) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
748 (const :tag "Immortal" immortal)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
749 (choice |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
750 :tag "Title/Description" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
751 (const :tag "Title" title) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
752 (const :tag "Description" description) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
753 (const :tag "All" all)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
754 (string :tag "Regexp"))))) |
65468 | 755 :group 'newsticker-headline-processing) |
756 | |
757 ;; customization group layout | |
758 (defgroup newsticker-layout nil | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
759 "Settings for layout of the feed reader." |
65468 | 760 :group 'newsticker) |
761 | |
762 (defcustom newsticker-sort-method | |
763 'sort-by-original-order | |
764 "Sort method for news items. | |
765 The following sort methods are available: | |
766 * `sort-by-original-order' keeps the order in which the items | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
767 appear in the headline file (please note that for immortal items, |
65468 | 768 which have been removed from the news feed, there is no original |
769 order), | |
770 * `sort-by-time' looks at the time at which an item has been seen | |
771 the first time. The most recent item is put at top, | |
772 * `sort-by-title' will put the items in an alphabetical order." | |
773 :type '(choice | |
774 (const :tag "Keep original order" sort-by-original-order) | |
775 (const :tag "Sort by time" sort-by-time) | |
776 (const :tag "Sort by title" sort-by-title)) | |
777 :set 'newsticker--set-customvar | |
778 :group 'newsticker-layout) | |
779 | |
780 (defcustom newsticker-hide-old-items-in-newsticker-buffer | |
781 nil | |
782 "Decides whether to automatically hide old items in the *newsticker* buffer. | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
783 If set to t old items will be completely folded and only new |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
784 items will show up in the *newsticker* buffer. Otherwise old as |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
785 well as new items will be visible." |
65468 | 786 :type 'boolean |
787 :set 'newsticker--set-customvar | |
788 :group 'newsticker-layout) | |
789 | |
790 (defcustom newsticker-show-descriptions-of-new-items | |
791 t | |
792 "Whether to automatically show descriptions of new items in *newsticker*. | |
793 If set to t old items will be folded and new items will be | |
794 unfolded. Otherwise old as well as new items will be folded." | |
795 :type 'boolean | |
796 :set 'newsticker--set-customvar | |
797 :group 'newsticker-layout) | |
798 | |
799 (defcustom newsticker-heading-format | |
800 "%l | |
801 %t %d %s" | |
802 "Format string for feed headings. | |
803 The following printf-like specifiers can be used: | |
804 %d The date the feed was retrieved. See `newsticker-date-format'. | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
805 %l The logo (image) of the feed. Most news feeds provide a small |
65468 | 806 image as logo. Newsticker can display them, if Emacs can -- |
807 see `image-types' for a list of supported image types. | |
808 %L The logo (image) of the feed. If the logo is not available | |
809 the title of the feed is used. | |
810 %s The statistical data of the feed. See `newsticker-statistics-format'. | |
811 %t The title of the feed, i.e. its name." | |
812 :type 'string | |
813 :set 'newsticker--set-customvar | |
814 :group 'newsticker-layout) | |
815 | |
816 (defcustom newsticker-item-format | |
817 "%t %d" | |
818 "Format string for news item headlines. | |
819 The following printf-like specifiers can be used: | |
820 %d The date the item was (first) retrieved. See `newsticker-date-format'. | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
821 %l The logo (image) of the feed. Most news feeds provide a small |
65468 | 822 image as logo. Newsticker can display them, if Emacs can -- |
823 see `image-types' for a list of supported image types. | |
824 %L The logo (image) of the feed. If the logo is not available | |
825 the title of the feed is used. | |
826 %t The title of the item." | |
827 :type 'string | |
828 :set 'newsticker--set-customvar | |
829 :group 'newsticker-layout) | |
830 | |
831 (defcustom newsticker-desc-format | |
832 "%d %c" | |
833 "Format string for news descriptions (contents). | |
834 The following printf-like specifiers can be used: | |
835 %c The contents (description) of the item. | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
836 %d The date the item was (first) retrieved. See |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
837 `newsticker-date-format'." |
65468 | 838 :type 'string |
839 :set 'newsticker--set-customvar | |
840 :group 'newsticker-layout) | |
841 | |
842 (defcustom newsticker-date-format | |
843 "(%A, %H:%M)" | |
844 "Format for the date part in item and feed lines. | |
845 See `format-time-string' for a list of valid specifiers." | |
846 :type 'string | |
847 :set 'newsticker--set-customvar | |
848 :group 'newsticker-layout) | |
849 | |
850 (defcustom newsticker-statistics-format | |
851 "[%n + %i + %o + %O = %a]" | |
852 "Format for the statistics part in feed lines. | |
853 The following printf-like specifiers can be used: | |
854 %a The number of all items in the feed. | |
855 %i The number of immortal items in the feed. | |
856 %n The number of new items in the feed. | |
857 %o The number of old items in the feed. | |
858 %O The number of obsolete items in the feed." | |
859 :type 'string | |
860 :set 'newsticker--set-customvar | |
861 :group 'newsticker-layout) | |
862 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
863 (defcustom newsticker-show-all-news-elements |
65468 | 864 nil |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
865 "Show all news elements." |
65468 | 866 :type 'boolean |
867 ;;:set 'newsticker--set-customvar | |
868 :group 'newsticker-layout) | |
869 | |
870 ;; image related things | |
871 (defcustom newsticker-enable-logo-manipulations | |
872 t | |
873 "If non-nil newsticker manipulates logo images. | |
874 This enables the following image properties: heuristic mask for all | |
875 logos, and laplace-conversion for images without new items." | |
876 :type 'boolean | |
877 :group 'newsticker-layout) | |
878 | |
879 | |
880 ;; rendering | |
881 (defcustom newsticker-justification | |
882 'left | |
883 "How to fill item descriptions. | |
884 If non-nil newsticker calls `fill-region' to wrap long lines in | |
885 item descriptions. However, if an item description contains HTML | |
886 text and `newsticker-html-renderer' is non-nil, filling is not | |
887 done." | |
888 :type '(choice :tag "Justification" | |
889 (const :tag "No filling" nil) | |
890 (const :tag "Left" left) | |
891 (const :tag "Right" right) | |
892 (const :tag "Center" center) | |
893 (const :tag "Full" full)) | |
894 :set 'newsticker--set-customvar | |
895 :group 'newsticker-layout) | |
896 | |
897 (defcustom newsticker-use-full-width | |
898 t | |
899 "Decides whether to use the full window width when filling. | |
900 If non-nil newsticker sets `fill-column' so that the whole | |
901 window is used when filling. See also `newsticker-justification'." | |
902 :type 'boolean | |
903 :set 'newsticker--set-customvar | |
904 :group 'newsticker-layout) | |
905 | |
906 (defcustom newsticker-html-renderer | |
907 nil | |
908 "Function for rendering HTML contents. | |
909 If non-nil, newsticker.el will call this function whenever it finds | |
910 HTML-like tags in item descriptions. Possible functions are, for | |
911 example, `w3m-region', `w3-region', and (if you have htmlr.el installed) | |
912 `newsticker-htmlr-render'. | |
913 | |
914 In order to make sure that the HTML renderer is loaded when you | |
915 run newsticker, you should add one of the following statements to | |
916 your .emacs. If you use w3m, | |
917 | |
918 (autoload 'w3m-region \"w3m\" | |
919 \"Render region in current buffer and replace with result.\" t) | |
920 | |
921 or, if you use w3, | |
922 | |
923 (require 'w3-auto) | |
924 | |
925 or, if you use htmlr | |
926 | |
927 (require 'htmlr)" | |
928 :type '(choice :tag "Function" | |
929 (const :tag "None" nil) | |
930 (const :tag "w3" w3-region) | |
931 (const :tag "w3m" w3m-region) | |
932 (const :tag "htmlr" newsticker-htmlr-render)) | |
933 :set 'newsticker--set-customvar | |
934 :group 'newsticker-layout) | |
935 | |
936 | |
937 ;; faces | |
938 (defgroup newsticker-faces nil | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
939 "Settings for the faces of the feed reader." |
65468 | 940 :group 'newsticker-layout) |
941 | |
942 (defface newsticker-feed-face | |
943 '((((class color) (background dark)) | |
944 (:family "helvetica" :bold t :height 1.2 :foreground "misty rose")) | |
945 (((class color) (background light)) | |
946 (:family "helvetica" :bold t :height 1.2 :foreground "black"))) | |
947 "Face for news feeds." | |
948 :group 'newsticker-faces) | |
949 | |
950 (defface newsticker-new-item-face | |
951 '((((class color) (background dark)) | |
952 (:family "helvetica" :bold t)) | |
953 (((class color) (background light)) | |
954 (:family "helvetica" :bold t))) | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
955 "Face for new news items." |
65468 | 956 :group 'newsticker-faces) |
957 | |
958 (defface newsticker-old-item-face | |
959 '((((class color) (background dark)) | |
960 (:family "helvetica" :bold t :foreground "orange3")) | |
961 (((class color) (background light)) | |
962 (:family "helvetica" :bold t :foreground "red4"))) | |
963 "Face for old news items." | |
964 :group 'newsticker-faces) | |
965 | |
966 (defface newsticker-immortal-item-face | |
967 '((((class color) (background dark)) | |
968 (:family "helvetica" :bold t :italic t :foreground "orange")) | |
969 (((class color) (background light)) | |
970 (:family "helvetica" :bold t :italic t :foreground "blue"))) | |
971 "Face for immortal news items." | |
972 :group 'newsticker-faces) | |
973 | |
974 (defface newsticker-obsolete-item-face | |
975 '((((class color) (background dark)) | |
976 (:family "helvetica" :bold t :strike-through t)) | |
977 (((class color) (background light)) | |
978 (:family "helvetica" :bold t :strike-through t))) | |
979 "Face for old news items." | |
980 :group 'newsticker-faces) | |
981 | |
982 (defface newsticker-date-face | |
983 '((((class color) (background dark)) | |
984 (:family "helvetica" :italic t :height 0.8)) | |
985 (((class color) (background light)) | |
986 (:family "helvetica" :italic t :height 0.8))) | |
987 "Face for newsticker dates." | |
988 :group 'newsticker-faces) | |
989 | |
990 (defface newsticker-statistics-face | |
991 '((((class color) (background dark)) | |
992 (:family "helvetica" :italic t :height 0.8)) | |
993 (((class color) (background light)) | |
994 (:family "helvetica" :italic t :height 0.8))) | |
995 "Face for newsticker dates." | |
996 :group 'newsticker-faces) | |
997 | |
998 (defface newsticker-enclosure-face | |
999 '((((class color) (background dark)) | |
1000 (:bold t :background "orange")) | |
1001 (((class color) (background light)) | |
1002 (:bold t :background "orange"))) | |
1003 "Face for enclosed elements." | |
1004 :group 'newsticker-faces) | |
1005 | |
1006 (defface newsticker-extra-face | |
1007 '((((class color) (background dark)) | |
1008 (:italic t :foreground "gray50" :height 0.8)) | |
1009 (((class color) (background light)) | |
1010 (:italic t :foreground "gray50" :height 0.8))) | |
1011 "Face for newsticker dates." | |
1012 :group 'newsticker-faces) | |
1013 | |
1014 ;; (defface newsticker-default-face | |
1015 ;; '((((class color) (background dark)) | |
1016 ;; (:inherit default)) | |
1017 ;; (((class color) (background light)) | |
1018 ;; (:inherit default))) | |
1019 ;; "Face for the description of news items." | |
1020 ;; ;;:set 'newsticker--set-customvar | |
1021 ;; :group 'newsticker-faces) | |
1022 | |
1023 | |
1024 ;; customization group ticker | |
1025 (defgroup newsticker-ticker nil | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
1026 "Settings for the headline ticker." |
65468 | 1027 :group 'newsticker) |
1028 | |
1029 (defcustom newsticker-display-interval | |
1030 0.3 | |
1031 "Time interval for displaying news items in the echo area (seconds). | |
1032 If equal or less than 0 no messages are shown in the echo area. For | |
1033 smooth display (see `newsticker-scroll-smoothly') a value of 0.3 seems | |
1034 reasonable. For non-smooth display a value of 10 is a good starting | |
1035 point." | |
1036 :type 'number | |
1037 :set 'newsticker--set-customvar | |
1038 :group 'newsticker-ticker) | |
1039 | |
1040 (defcustom newsticker-scroll-smoothly | |
1041 t | |
1042 "Decides whether to flash or scroll news items. | |
1043 If t the news headlines are scrolled (more-or-less) smoothly in the echo | |
1044 area. If nil one headline after another is displayed in the echo area. | |
1045 The variable `newsticker-display-interval' determines how fast this | |
1046 display moves/changes and whether headlines are shown in the echo area | |
1047 at all. If you change `newsticker-scroll-smoothly' you should also change | |
1048 `newsticker-display-interval'." | |
1049 :type 'boolean | |
1050 :group 'newsticker-ticker) | |
1051 | |
1052 (defcustom newsticker-hide-immortal-items-in-echo-area | |
1053 t | |
1054 "Decides whether to show immortal/non-expiring news items in the ticker. | |
1055 If t the echo area will not show immortal items. See also | |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
1056 `newsticker-hide-old-items-in-echo-area'." |
65468 | 1057 :type 'boolean |
1058 :set 'newsticker--set-customvar | |
1059 :group 'newsticker-ticker) | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
1060 |
65468 | 1061 (defcustom newsticker-hide-old-items-in-echo-area |
1062 t | |
1063 "Decides whether to show only the newest news items in the ticker. | |
1064 If t the echo area will show only new items, i.e. only items which have | |
1065 been added between the last two retrievals." | |
1066 :type 'boolean | |
1067 :set 'newsticker--set-customvar | |
1068 :group 'newsticker-ticker) | |
1069 | |
1070 (defcustom newsticker-hide-obsolete-items-in-echo-area | |
1071 t | |
1072 "Decides whether to show obsolete items items in the ticker. | |
1073 If t the echo area will not show obsolete items. See also | |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
1074 `newsticker-hide-old-items-in-echo-area'." |
65468 | 1075 :type 'boolean |
1076 :set 'newsticker--set-customvar | |
1077 :group 'newsticker-ticker) | |
1078 | |
1079 (defgroup newsticker-hooks nil | |
1080 "Settings for newsticker hooks." | |
1081 :group 'newsticker) | |
1082 | |
1083 (defcustom newsticker-start-hook | |
1084 nil | |
1085 "Hook run when starting newsticker. | |
1086 This hook is run at the very end of `newsticker-start'." | |
1087 :options '(newsticker-start-ticker) | |
1088 :type 'hook | |
1089 :group 'newsticker-hooks) | |
1090 | |
1091 (defcustom newsticker-stop-hook | |
1092 nil | |
1093 "Hook run when stopping newsticker. | |
1094 This hook is run at the very end of `newsticker-stop'." | |
1095 :options nil | |
1096 :type 'hook | |
1097 :group 'newsticker-hooks) | |
1098 | |
1099 (defcustom newsticker-new-item-functions | |
1100 nil | |
1101 "List of functions run after a new headline has been retrieved. | |
1102 Each function is called with the following three arguments: | |
1103 FEED the name of the corresponding news feed, | |
1104 TITLE the title of the headline, | |
1105 DESC the decoded description of the headline. | |
1106 | |
1107 See `newsticker-download-images', and | |
1108 `newsticker-download-enclosures' for sample functions. | |
1109 | |
1110 Please note that these functions are called only once for a | |
1111 headline after it has been retrieved for the first time." | |
1112 :type 'hook | |
1113 :options '(newsticker-download-images | |
1114 newsticker-download-enclosures) | |
1115 :group 'newsticker-hooks) | |
1116 | |
1117 (defcustom newsticker-select-item-hook | |
1118 'newsticker--buffer-make-item-completely-visible | |
1119 "List of functions run after a headline has been selected. | |
1120 Each function is called after one of `newsticker-next-item', | |
1121 `newsticker-next-new-item', `newsticker-previous-item', | |
1122 `newsticker-previous-new-item' has been called. | |
1123 | |
1124 The default value 'newsticker--buffer-make-item-completely-visible | |
1125 assures that the current item is always completely visible." | |
1126 :type 'hook | |
1127 :options '(newsticker--buffer-make-item-completely-visible) | |
1128 :group 'newsticker-hooks) | |
1129 | |
1130 (defcustom newsticker-select-feed-hook | |
1131 'newsticker--buffer-make-item-completely-visible | |
1132 "List of functions run after a feed has been selected. | |
1133 Each function is called after one of `newsticker-next-feed', and | |
1134 `newsticker-previous-feed' has been called. | |
1135 | |
1136 The default value 'newsticker--buffer-make-item-completely-visible | |
1137 assures that the current feed is completely visible." | |
1138 :type 'hook | |
1139 :options '(newsticker--buffer-make-item-completely-visible) | |
1140 :group 'newsticker-hooks) | |
1141 | |
1142 (defcustom newsticker-buffer-change-hook | |
1143 'newsticker-w3m-show-inline-images | |
1144 "List of functions run after the newsticker buffer has been updated. | |
1145 Each function is called after `newsticker-buffer-update' has been called. | |
1146 | |
1147 The default value '`newsticker-w3m-show-inline-images' loads inline | |
1148 images." | |
1149 :type 'hook | |
1150 :group 'newsticker-hooks) | |
1151 | |
1152 (defcustom newsticker-narrow-hook | |
1153 'newsticker-w3m-show-inline-images | |
1154 "List of functions run after narrowing in newsticker buffer has changed. | |
1155 Each function is called after | |
1156 `newsticker-toggle-auto-narrow-to-feed' or | |
1157 `newsticker-toggle-auto-narrow-to-item' has been called. | |
1158 | |
1159 The default value '`newsticker-w3m-show-inline-images' loads inline | |
1160 images." | |
1161 :type 'hook | |
1162 :group 'newsticker-hooks) | |
1163 | |
1164 (defgroup newsticker-miscellaneous nil | |
1165 "Miscellaneous newsticker settings." | |
1166 :group 'newsticker) | |
1167 | |
1168 (defcustom newsticker-cache-filename | |
1169 "~/.newsticker-cache" | |
1170 "Name of the newsticker cache file." | |
1171 :type 'string | |
1172 :group 'newsticker-miscellaneous) | |
1173 | |
1174 (defcustom newsticker-imagecache-dirname | |
1175 "~/.newsticker-images" | |
1176 "Name of the directory where newsticker stores cached images." | |
1177 :type 'string | |
1178 :group 'newsticker-miscellaneous) | |
1179 | |
1180 ;; debugging | |
1181 (defcustom newsticker-debug | |
1182 nil | |
1183 "Enables some features needed for debugging newsticker.el. | |
1184 | |
1185 If set to t newsticker.el will print lots of debugging messages, and the | |
1186 buffers *newsticker-wget-<feed>* will not be closed." | |
1187 :type 'boolean | |
1188 ;;:set 'newsticker--set-customvar | |
1189 :group 'newsticker-miscellaneous) | |
1190 | |
1191 ;; ====================================================================== | |
1192 ;;; Compatibility section, XEmacs, Emacs | |
1193 ;; ====================================================================== | |
1194 (unless (fboundp 'time-add) | |
1195 (require 'time-date);;FIXME | |
1196 (defun time-add (t1 t2) | |
1197 (seconds-to-time (+ (time-to-seconds t1) (time-to-seconds t2))))) | |
1198 | |
1199 (unless (fboundp 'match-string-no-properties) | |
1200 (defalias 'match-string-no-properties 'match-string)) | |
1201 | |
1202 (unless (fboundp 'replace-regexp-in-string) | |
1203 (defun replace-regexp-in-string (re rp st) | |
1204 (save-match-data ;; apparently XEmacs needs save-match-data | |
1205 (replace-in-string st re rp)))) | |
1206 | |
1207 ;; copied from subr.el | |
1208 (unless (fboundp 'add-to-invisibility-spec) | |
1209 (defun add-to-invisibility-spec (arg) | |
1210 "Add elements to `buffer-invisibility-spec'. | |
1211 See documentation for `buffer-invisibility-spec' for the kind of elements | |
1212 that can be added." | |
1213 (if (eq buffer-invisibility-spec t) | |
1214 (setq buffer-invisibility-spec (list t))) | |
1215 (setq buffer-invisibility-spec | |
1216 (cons arg buffer-invisibility-spec)))) | |
1217 | |
1218 ;; copied from subr.el | |
1219 (unless (fboundp 'remove-from-invisibility-spec) | |
1220 (defun remove-from-invisibility-spec (arg) | |
1221 "Remove elements from `buffer-invisibility-spec'." | |
1222 (if (consp buffer-invisibility-spec) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
1223 (setq buffer-invisibility-spec |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
1224 (delete arg buffer-invisibility-spec))))) |
65468 | 1225 |
1226 ;; ====================================================================== | |
1227 ;;; Internal variables | |
1228 ;; ====================================================================== | |
1229 (defvar newsticker--item-list nil | |
1230 "List of newsticker items.") | |
1231 (defvar newsticker--item-position 0 | |
1232 "Actual position in list of newsticker items.") | |
1233 (defvar newsticker--prev-message "There was no previous message yet!" | |
1234 "Last message that the newsticker displayed.") | |
1235 (defvar newsticker--scrollable-text "" | |
1236 "The text which is scrolled smoothly in the echo area.") | |
1237 (defvar newsticker--buffer-uptodate-p nil | |
1238 "Tells whether the newsticker buffer is up to date.") | |
1239 (defvar newsticker--latest-update-time (current-time) | |
1240 "The time at which the latest news arrived.") | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
1241 (defvar newsticker--process-ids nil |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
1242 "List of PIDs of active newsticker processes.") |
65468 | 1243 |
1244 (defvar newsticker--cache nil "Cached newsticker data. | |
1245 This is a list of the form | |
1246 | |
1247 ((label1 | |
1248 (title description link time age index preformatted-contents | |
1249 preformatted-title) | |
1250 ...) | |
1251 (label2 | |
1252 (title description link time age index preformatted-contents | |
1253 preformatted-title) | |
1254 ...) | |
1255 ...) | |
1256 | |
1257 where LABEL is a symbol. TITLE, DESCRIPTION, and LINK are | |
1258 strings. TIME is a time value as returned by `current-time'. | |
1259 AGE is a symbol: 'new, 'old, 'immortal, and 'obsolete denote | |
1260 ordinary news items, whereas 'feed denotes an item which is not a | |
1261 headline but describes the feed itself. INDEX denotes the | |
1262 original position of the item -- used for restoring the original | |
1263 order. PREFORMATTED-CONTENTS and PREFORMATTED-TITLE hold the | |
1264 formatted contents of the item's description and title. This | |
1265 speeds things up if HTML rendering is used, which is rather | |
1266 slow.") | |
1267 | |
1268 (defvar newsticker--auto-narrow-to-feed nil | |
1269 "Automatically narrow to current news feed. | |
1270 If non-nil only the items of the current news feed are visible.") | |
1271 | |
1272 (defvar newsticker--auto-narrow-to-item nil | |
1273 "Automatically narrow to current news item. | |
1274 If non-nil only the current headline is visible.") | |
1275 | |
1276 (defconst newsticker--error-headline | |
1277 "[COULD NOT DOWNLOAD HEADLINES!]" | |
1278 "Title of error headline which will be inserted if news retrieval fails.") | |
1279 | |
1280 ;; ====================================================================== | |
1281 ;;; Toolbar | |
1282 ;; ====================================================================== | |
1283 (defconst newsticker--next-item-image | |
1284 (if (fboundp 'create-image) | |
1285 (create-image "/* XPM */ | |
1286 static char * next_xpm[] = { | |
1287 \"24 24 42 1\", | |
1288 \" c None\", | |
1289 \". c #000000\", | |
1290 \"+ c #7EB6DE\", | |
1291 \"@ c #82BBE2\", | |
1292 \"# c #85BEE4\", | |
1293 \"$ c #88C1E7\", | |
1294 \"% c #8AC3E8\", | |
1295 \"& c #87C1E6\", | |
1296 \"* c #8AC4E9\", | |
1297 \"= c #8CC6EA\", | |
1298 \"- c #8CC6EB\", | |
1299 \"; c #88C2E7\", | |
1300 \"> c #8BC5E9\", | |
1301 \", c #8DC7EB\", | |
1302 \"' c #87C0E6\", | |
1303 \") c #8AC4E8\", | |
1304 \"! c #8BC5EA\", | |
1305 \"~ c #8BC4E9\", | |
1306 \"{ c #88C1E6\", | |
1307 \"] c #89C3E8\", | |
1308 \"^ c #86BFE5\", | |
1309 \"/ c #83BBE2\", | |
1310 \"( c #82BBE1\", | |
1311 \"_ c #86C0E5\", | |
1312 \": c #87C0E5\", | |
1313 \"< c #83BCE2\", | |
1314 \"[ c #81B9E0\", | |
1315 \"} c #81BAE1\", | |
1316 \"| c #78B0D9\", | |
1317 \"1 c #7BB3DB\", | |
1318 \"2 c #7DB5DD\", | |
1319 \"3 c #7DB6DD\", | |
1320 \"4 c #72A9D4\", | |
1321 \"5 c #75ACD6\", | |
1322 \"6 c #76AED7\", | |
1323 \"7 c #77AFD8\", | |
1324 \"8 c #6BA1CD\", | |
1325 \"9 c #6EA4CF\", | |
1326 \"0 c #6FA6D1\", | |
1327 \"a c #6298C6\", | |
1328 \"b c #659BC8\", | |
1329 \"c c #5C91C0\", | |
1330 \" \", | |
1331 \" \", | |
1332 \" . \", | |
1333 \" .. \", | |
1334 \" .+. \", | |
1335 \" .@#. \", | |
1336 \" .#$%. \", | |
1337 \" .&*=-. \", | |
1338 \" .;>,,,. \", | |
1339 \" .;>,,,=. \", | |
1340 \" .')!==~;. \", | |
1341 \" .#{]*%;^/. \", | |
1342 \" .(#_':#<. \", | |
1343 \" .+[@</}. \", | |
1344 \" .|1232. \", | |
1345 \" .4567. \", | |
1346 \" .890. \", | |
1347 \" .ab. \", | |
1348 \" .c. \", | |
1349 \" .. \", | |
1350 \" . \", | |
1351 \" \", | |
1352 \" \", | |
1353 \" \"}; | |
1354 " | |
1355 'xpm t) | |
1356 "Image for the next item button.")) | |
1357 | |
1358 (defconst newsticker--previous-item-image | |
1359 (if (fboundp 'create-image) | |
1360 (create-image "/* XPM */ | |
1361 static char * previous_xpm[] = { | |
1362 \"24 24 39 1\", | |
1363 \" c None\", | |
1364 \". c #000000\", | |
1365 \"+ c #7BB3DB\", | |
1366 \"@ c #83BCE2\", | |
1367 \"# c #7FB8DF\", | |
1368 \"$ c #89C2E7\", | |
1369 \"% c #86BFE5\", | |
1370 \"& c #83BBE2\", | |
1371 \"* c #8CC6EA\", | |
1372 \"= c #8BC4E9\", | |
1373 \"- c #88C2E7\", | |
1374 \"; c #85BEE4\", | |
1375 \"> c #8DC7EB\", | |
1376 \", c #89C3E8\", | |
1377 \"' c #8AC4E8\", | |
1378 \") c #8BC5EA\", | |
1379 \"! c #88C1E6\", | |
1380 \"~ c #8AC4E9\", | |
1381 \"{ c #8AC3E8\", | |
1382 \"] c #86C0E5\", | |
1383 \"^ c #87C0E6\", | |
1384 \"/ c #87C0E5\", | |
1385 \"( c #82BBE2\", | |
1386 \"_ c #81BAE1\", | |
1387 \": c #7FB7DF\", | |
1388 \"< c #7DB6DD\", | |
1389 \"[ c #7DB5DD\", | |
1390 \"} c #7CB4DC\", | |
1391 \"| c #79B1DA\", | |
1392 \"1 c #76ADD7\", | |
1393 \"2 c #77AFD8\", | |
1394 \"3 c #73AAD4\", | |
1395 \"4 c #70A7D1\", | |
1396 \"5 c #6EA5D0\", | |
1397 \"6 c #6CA2CE\", | |
1398 \"7 c #689ECB\", | |
1399 \"8 c #6399C7\", | |
1400 \"9 c #6095C4\", | |
1401 \"0 c #5C90C0\", | |
1402 \" \", | |
1403 \" \", | |
1404 \" . \", | |
1405 \" .. \", | |
1406 \" .+. \", | |
1407 \" .@#. \", | |
1408 \" .$%&. \", | |
1409 \" .*=-;. \", | |
1410 \" .>>*,%. \", | |
1411 \" .>>>*,%. \", | |
1412 \" .')**=-;. \", | |
1413 \" .;!,~{-%&. \", | |
1414 \" .;]^/;@#. \", | |
1415 \" .(@&_:+. \", | |
1416 \" .<[}|1. \", | |
1417 \" .2134. \", | |
1418 \" .567. \", | |
1419 \" .89. \", | |
1420 \" .0. \", | |
1421 \" .. \", | |
1422 \" . \", | |
1423 \" \", | |
1424 \" \", | |
1425 \" \"}; | |
1426 " | |
1427 'xpm t) | |
1428 "Image for the previous item button.")) | |
1429 | |
1430 (defconst newsticker--previous-feed-image | |
1431 (if (fboundp 'create-image) | |
1432 (create-image "/* XPM */ | |
1433 static char * prev_feed_xpm[] = { | |
1434 \"24 24 52 1\", | |
1435 \" c None\", | |
1436 \". c #000000\", | |
1437 \"+ c #70A7D2\", | |
1438 \"@ c #75ADD6\", | |
1439 \"# c #71A8D3\", | |
1440 \"$ c #79B1DA\", | |
1441 \"% c #7BB3DB\", | |
1442 \"& c #7DB5DD\", | |
1443 \"* c #83BBE2\", | |
1444 \"= c #7EB6DE\", | |
1445 \"- c #78B0D9\", | |
1446 \"; c #7FB7DE\", | |
1447 \"> c #88C2E7\", | |
1448 \", c #85BEE4\", | |
1449 \"' c #80B9E0\", | |
1450 \") c #80B8DF\", | |
1451 \"! c #8CC6EA\", | |
1452 \"~ c #89C3E8\", | |
1453 \"{ c #86BFE5\", | |
1454 \"] c #81BAE1\", | |
1455 \"^ c #7CB4DC\", | |
1456 \"/ c #7FB8DF\", | |
1457 \"( c #8DC7EB\", | |
1458 \"_ c #7BB3DC\", | |
1459 \": c #7EB7DE\", | |
1460 \"< c #8BC4E9\", | |
1461 \"[ c #8AC4E9\", | |
1462 \"} c #8AC3E8\", | |
1463 \"| c #87C0E6\", | |
1464 \"1 c #87C0E5\", | |
1465 \"2 c #83BCE2\", | |
1466 \"3 c #75ACD6\", | |
1467 \"4 c #7FB7DF\", | |
1468 \"5 c #77AED8\", | |
1469 \"6 c #71A8D2\", | |
1470 \"7 c #70A7D1\", | |
1471 \"8 c #76ADD7\", | |
1472 \"9 c #6CA2CE\", | |
1473 \"0 c #699FCC\", | |
1474 \"a c #73AAD4\", | |
1475 \"b c #6BA1CD\", | |
1476 \"c c #669CC9\", | |
1477 \"d c #6298C5\", | |
1478 \"e c #689ECB\", | |
1479 \"f c #6499C7\", | |
1480 \"g c #6095C3\", | |
1481 \"h c #5C91C0\", | |
1482 \"i c #5E93C2\", | |
1483 \"j c #5B90C0\", | |
1484 \"k c #588CBC\", | |
1485 \"l c #578CBC\", | |
1486 \"m c #5589BA\", | |
1487 \" \", | |
1488 \" \", | |
1489 \" ... . \", | |
1490 \" .+. .. \", | |
1491 \" .@. .#. \", | |
1492 \" .$. .%@. \", | |
1493 \" .&. .*=-. \", | |
1494 \" .;. .>,'%. \", | |
1495 \" .). .!~{]^. \", | |
1496 \" ./. .(!~{]_. \", | |
1497 \" .:. .!!<>,'%. \", | |
1498 \" .&. .~[}>{*=-. \", | |
1499 \" .$. .|1,2/%@. \", | |
1500 \" .3. .*]4%56. \", | |
1501 \" .7. .^$8#9. \", | |
1502 \" .0. .a7bc. \", | |
1503 \" .d. .efg. \", | |
1504 \" .h. .ij. \", | |
1505 \" .k. .l. \", | |
1506 \" .m. .. \", | |
1507 \" ... . \", | |
1508 \" \", | |
1509 \" \", | |
1510 \" \"}; | |
1511 " | |
1512 'xpm t) | |
1513 "Image for the previous feed button.")) | |
1514 | |
1515 (defconst newsticker--next-feed-image | |
1516 (if (fboundp 'create-image) | |
1517 (create-image "/* XPM */ | |
1518 static char * next_feed_xpm[] = { | |
1519 \"24 24 57 1\", | |
1520 \" c None\", | |
1521 \". c #000000\", | |
1522 \"+ c #6CA2CE\", | |
1523 \"@ c #75ADD6\", | |
1524 \"# c #71A8D3\", | |
1525 \"$ c #79B1DA\", | |
1526 \"% c #7EB7DE\", | |
1527 \"& c #7DB5DD\", | |
1528 \"* c #81BAE1\", | |
1529 \"= c #85BEE4\", | |
1530 \"- c #78B0D9\", | |
1531 \"; c #7FB7DE\", | |
1532 \"> c #83BCE3\", | |
1533 \", c #87C1E6\", | |
1534 \"' c #8AC4E9\", | |
1535 \") c #7BB3DB\", | |
1536 \"! c #80B8DF\", | |
1537 \"~ c #88C2E7\", | |
1538 \"{ c #8BC5E9\", | |
1539 \"] c #8DC7EB\", | |
1540 \"^ c #7CB4DC\", | |
1541 \"/ c #7FB8DF\", | |
1542 \"( c #84BDE3\", | |
1543 \"_ c #7BB3DC\", | |
1544 \": c #83BCE2\", | |
1545 \"< c #87C0E6\", | |
1546 \"[ c #8AC4E8\", | |
1547 \"} c #8BC5EA\", | |
1548 \"| c #8CC6EA\", | |
1549 \"1 c #88C1E6\", | |
1550 \"2 c #89C3E8\", | |
1551 \"3 c #8AC3E8\", | |
1552 \"4 c #7EB6DE\", | |
1553 \"5 c #82BBE1\", | |
1554 \"6 c #86C0E5\", | |
1555 \"7 c #87C0E5\", | |
1556 \"8 c #75ACD6\", | |
1557 \"9 c #7AB2DA\", | |
1558 \"0 c #81B9E0\", | |
1559 \"a c #82BBE2\", | |
1560 \"b c #71A8D2\", | |
1561 \"c c #70A7D1\", | |
1562 \"d c #74ACD6\", | |
1563 \"e c #699FCC\", | |
1564 \"f c #6EA5D0\", | |
1565 \"g c #72A9D4\", | |
1566 \"h c #669CC9\", | |
1567 \"i c #6298C5\", | |
1568 \"j c #679DCA\", | |
1569 \"k c #6BA1CD\", | |
1570 \"l c #6095C3\", | |
1571 \"m c #5C91C0\", | |
1572 \"n c #5F94C2\", | |
1573 \"o c #5B90C0\", | |
1574 \"p c #588CBC\", | |
1575 \"q c #578CBC\", | |
1576 \"r c #5589BA\", | |
1577 \" \", | |
1578 \" \", | |
1579 \" . ... \", | |
1580 \" .. .+. \", | |
1581 \" .@. .#. \", | |
1582 \" .$%. .@. \", | |
1583 \" .&*=. .-. \", | |
1584 \" .;>,'. .). \", | |
1585 \" .!=~{]. .^. \", | |
1586 \" ./(~{]]. ._. \", | |
1587 \" .%:<[}||. .). \", | |
1588 \" .&*=12'3~. .-. \", | |
1589 \" .$45=6<7. .@. \", | |
1590 \" .8940a:. .b. \", | |
1591 \" .cd-)&. .+. \", | |
1592 \" .efg8. .h. \", | |
1593 \" .ijk. .l. \", | |
1594 \" .mn. .o. \", | |
1595 \" .p. .q. \", | |
1596 \" .. .r. \", | |
1597 \" . ... \", | |
1598 \" \", | |
1599 \" \", | |
1600 \" \"}; | |
1601 " | |
1602 'xpm t) | |
1603 "Image for the next feed button.")) | |
1604 | |
1605 (defconst newsticker--mark-read-image | |
1606 (if (fboundp 'create-image) | |
1607 (create-image "/* XPM */ | |
1608 static char * mark_read_xpm[] = { | |
1609 \"24 24 44 1\", | |
1610 \" c None\", | |
1611 \". c #C20000\", | |
1612 \"+ c #BE0000\", | |
1613 \"@ c #C70000\", | |
1614 \"# c #CE0000\", | |
1615 \"$ c #C90000\", | |
1616 \"% c #BD0000\", | |
1617 \"& c #CB0000\", | |
1618 \"* c #D10000\", | |
1619 \"= c #D70000\", | |
1620 \"- c #D30000\", | |
1621 \"; c #CD0000\", | |
1622 \"> c #C60000\", | |
1623 \", c #D40000\", | |
1624 \"' c #DA0000\", | |
1625 \") c #DE0000\", | |
1626 \"! c #DB0000\", | |
1627 \"~ c #D60000\", | |
1628 \"{ c #D00000\", | |
1629 \"] c #DC0000\", | |
1630 \"^ c #E00000\", | |
1631 \"/ c #E40000\", | |
1632 \"( c #E10000\", | |
1633 \"_ c #DD0000\", | |
1634 \": c #D80000\", | |
1635 \"< c #E50000\", | |
1636 \"[ c #E70000\", | |
1637 \"} c #E60000\", | |
1638 \"| c #E20000\", | |
1639 \"1 c #E90000\", | |
1640 \"2 c #E80000\", | |
1641 \"3 c #E30000\", | |
1642 \"4 c #DF0000\", | |
1643 \"5 c #D90000\", | |
1644 \"6 c #CC0000\", | |
1645 \"7 c #C10000\", | |
1646 \"8 c #C30000\", | |
1647 \"9 c #BF0000\", | |
1648 \"0 c #B90000\", | |
1649 \"a c #BC0000\", | |
1650 \"b c #BB0000\", | |
1651 \"c c #B80000\", | |
1652 \"d c #B50000\", | |
1653 \"e c #B70000\", | |
1654 \" \", | |
1655 \" \", | |
1656 \" \", | |
1657 \" . + \", | |
1658 \" +@# $.% \", | |
1659 \" &*= -;> \", | |
1660 \" ,') !~{ \", | |
1661 \" ]^/ (_: \", | |
1662 \" (<[ }|) \", | |
1663 \" <[1 2<| \", | |
1664 \" }222[< \", | |
1665 \" }}}< \", | |
1666 \" 333| \", | |
1667 \" _4^4)] \", | |
1668 \" ~:' 5=- \", | |
1669 \" 6{- *#$ \", | |
1670 \" 7>$ @89 \", | |
1671 \" 0a+ %bc \", | |
1672 \" ddc edd \", | |
1673 \" ddd ddd \", | |
1674 \" d d \", | |
1675 \" \", | |
1676 \" \", | |
1677 \" \"}; | |
1678 " | |
1679 'xpm t) | |
1680 "Image for the next feed button.")) | |
1681 | |
1682 (defconst newsticker--mark-immortal-image | |
1683 (if (fboundp 'create-image) | |
1684 (create-image "/* XPM */ | |
1685 static char * mark_immortal_xpm[] = { | |
1686 \"24 24 93 2\", | |
1687 \" c None\", | |
1688 \". c #171717\", | |
1689 \"+ c #030303\", | |
1690 \"@ c #000000\", | |
1691 \"# c #181818\", | |
1692 \"$ c #090909\", | |
1693 \"% c #FFC960\", | |
1694 \"& c #FFCB61\", | |
1695 \"* c #FFCB62\", | |
1696 \"= c #FFC961\", | |
1697 \"- c #FFC75F\", | |
1698 \"; c #FFC65E\", | |
1699 \"> c #FFCA61\", | |
1700 \", c #FFCD63\", | |
1701 \"' c #FFCF65\", | |
1702 \") c #FFD065\", | |
1703 \"! c #FFCE64\", | |
1704 \"~ c #FFC35C\", | |
1705 \"{ c #FFC45D\", | |
1706 \"] c #FFD166\", | |
1707 \"^ c #FFD267\", | |
1708 \"/ c #FFD368\", | |
1709 \"( c #FFD167\", | |
1710 \"_ c #FFC05A\", | |
1711 \": c #010101\", | |
1712 \"< c #040404\", | |
1713 \"[ c #FFCC62\", | |
1714 \"} c #FFD569\", | |
1715 \"| c #FFD56A\", | |
1716 \"1 c #FFC860\", | |
1717 \"2 c #FFC25B\", | |
1718 \"3 c #FFBB56\", | |
1719 \"4 c #020202\", | |
1720 \"5 c #060606\", | |
1721 \"6 c #FFC15B\", | |
1722 \"7 c #FFC85F\", | |
1723 \"8 c #FFD469\", | |
1724 \"9 c #FFD66A\", | |
1725 \"0 c #FFBC57\", | |
1726 \"a c #1B1B1B\", | |
1727 \"b c #070707\", | |
1728 \"c c #FFBA55\", | |
1729 \"d c #FFB451\", | |
1730 \"e c #FFB954\", | |
1731 \"f c #FFB350\", | |
1732 \"g c #FFB652\", | |
1733 \"h c #FFBE58\", | |
1734 \"i c #FFCD64\", | |
1735 \"j c #FFD066\", | |
1736 \"k c #FFC059\", | |
1737 \"l c #FFB14E\", | |
1738 \"m c #0B0B0B\", | |
1739 \"n c #FFBB55\", | |
1740 \"o c #FFC15A\", | |
1741 \"p c #FFB552\", | |
1742 \"q c #FFAD4B\", | |
1743 \"r c #080808\", | |
1744 \"s c #FFAF4C\", | |
1745 \"t c #FFB853\", | |
1746 \"u c #FFA948\", | |
1747 \"v c #050505\", | |
1748 \"w c #FFB04E\", | |
1749 \"x c #FFB753\", | |
1750 \"y c #FFBC56\", | |
1751 \"z c #FFC55D\", | |
1752 \"A c #FFC55E\", | |
1753 \"B c #FFC45C\", | |
1754 \"C c #FFBD57\", | |
1755 \"D c #FFB854\", | |
1756 \"E c #FFB34F\", | |
1757 \"F c #FFAB4A\", | |
1758 \"G c #FFA545\", | |
1759 \"H c #FFAA49\", | |
1760 \"I c #FFB04D\", | |
1761 \"J c #FFB551\", | |
1762 \"K c #FFBF58\", | |
1763 \"L c #FFB24F\", | |
1764 \"M c #FFAC4A\", | |
1765 \"N c #FFA646\", | |
1766 \"O c #FFA344\", | |
1767 \"P c #FFA848\", | |
1768 \"Q c #FFB14F\", | |
1769 \"R c #FFAF4D\", | |
1770 \"S c #FFA546\", | |
1771 \"T c #FFA243\", | |
1772 \"U c #FFA445\", | |
1773 \"V c #FFAE4C\", | |
1774 \"W c #FFA444\", | |
1775 \"X c #FFA142\", | |
1776 \"Y c #FF9F41\", | |
1777 \"Z c #0A0A0A\", | |
1778 \"` c #FF9E40\", | |
1779 \" . c #FF9F40\", | |
1780 \" \", | |
1781 \" \", | |
1782 \" \", | |
1783 \" . + @ @ + # \", | |
1784 \" $ @ % & * * = - + + \", | |
1785 \" @ ; > , ' ) ' ! * - ~ @ \", | |
1786 \" @ { > ! ] ^ / / ( ' * ; _ : \", | |
1787 \" < _ ; [ ) / } | } / ] , 1 2 3 4 \", | |
1788 \" 5 6 7 , ] 8 9 9 9 } ^ ! = ~ 0 a \", | |
1789 \" b c 6 - , ] 8 9 9 9 } ^ ! % ~ 0 d 5 \", | |
1790 \" : e _ ; * ) / 8 } } / ] , 1 2 3 f 5 \", | |
1791 \" : g h { = i j ^ / ^ ] ! * ; k e l m \", | |
1792 \" : f n o ; > , ' ) ' ! * - 2 0 p q r \", | |
1793 \" : s g 0 6 ; % > * * = - ~ h t l u r \", | |
1794 \" v u w x y k ~ z A z B o C D E F G b \", | |
1795 \" 5 H I J e 0 h K h C c x L M N . \", | |
1796 \" 4 O P q Q d g x g J L R H S T < \", | |
1797 \" @ T U P F q V q M H N W X + \", | |
1798 \" @ Y T O W G G W O X Y @ \", | |
1799 \" 4 Z ` Y Y Y .` 4 4 \", | |
1800 \" 5 : : @ @ Z \", | |
1801 \" \", | |
1802 \" \", | |
1803 \" \"}; | |
1804 " | |
1805 'xpm t) | |
1806 "Image for the next feed button.")) | |
1807 | |
1808 | |
1809 (defconst newsticker--narrow-image | |
1810 (if (fboundp 'create-image) | |
1811 (create-image "/* XPM */ | |
1812 static char * narrow_xpm[] = { | |
1813 \"24 24 48 1\", | |
1814 \" c None\", | |
1815 \". c #000000\", | |
1816 \"+ c #969696\", | |
1817 \"@ c #9E9E9E\", | |
1818 \"# c #A4A4A4\", | |
1819 \"$ c #AAAAAA\", | |
1820 \"% c #AEAEAE\", | |
1821 \"& c #B1B1B1\", | |
1822 \"* c #B3B3B3\", | |
1823 \"= c #B4B4B4\", | |
1824 \"- c #B2B2B2\", | |
1825 \"; c #AFAFAF\", | |
1826 \"> c #ABABAB\", | |
1827 \", c #A6A6A6\", | |
1828 \"' c #A0A0A0\", | |
1829 \") c #989898\", | |
1830 \"! c #909090\", | |
1831 \"~ c #73AAD4\", | |
1832 \"{ c #7AB2DA\", | |
1833 \"] c #7FB8DF\", | |
1834 \"^ c #84BDE3\", | |
1835 \"/ c #88C2E7\", | |
1836 \"( c #8BC5E9\", | |
1837 \"_ c #8DC7EB\", | |
1838 \": c #8CC6EA\", | |
1839 \"< c #89C3E8\", | |
1840 \"[ c #86BFE5\", | |
1841 \"} c #81BAE1\", | |
1842 \"| c #7BB3DC\", | |
1843 \"1 c #75ACD6\", | |
1844 \"2 c #6DA4CF\", | |
1845 \"3 c #979797\", | |
1846 \"4 c #A3A3A3\", | |
1847 \"5 c #A8A8A8\", | |
1848 \"6 c #ADADAD\", | |
1849 \"7 c #ACACAC\", | |
1850 \"8 c #A9A9A9\", | |
1851 \"9 c #A5A5A5\", | |
1852 \"0 c #9A9A9A\", | |
1853 \"a c #929292\", | |
1854 \"b c #8C8C8C\", | |
1855 \"c c #808080\", | |
1856 \"d c #818181\", | |
1857 \"e c #838383\", | |
1858 \"f c #848484\", | |
1859 \"g c #858585\", | |
1860 \"h c #868686\", | |
1861 \"i c #828282\", | |
1862 \" \", | |
1863 \" \", | |
1864 \" \", | |
1865 \" .................. \", | |
1866 \" .+@#$%&*=*-;>,')!. \", | |
1867 \" .................. \", | |
1868 \" \", | |
1869 \" \", | |
1870 \" .................. \", | |
1871 \" .~{]^/(___:<[}|12. \", | |
1872 \" .................. \", | |
1873 \" \", | |
1874 \" \", | |
1875 \" .................. \", | |
1876 \" .!3@45>666789'0ab. \", | |
1877 \" .................. \", | |
1878 \" \", | |
1879 \" \", | |
1880 \" .................. \", | |
1881 \" .cccdefghhgficccc. \", | |
1882 \" .................. \", | |
1883 \" \", | |
1884 \" \", | |
1885 \" \"}; | |
1886 " | |
1887 'xpm t) | |
1888 "Image for the next feed button.")) | |
1889 | |
1890 (defconst newsticker--get-all-image | |
1891 (if (fboundp 'create-image) | |
1892 (create-image "/* XPM */ | |
1893 static char * get_all_xpm[] = { | |
1894 \"24 24 70 1\", | |
1895 \" c None\", | |
1896 \". c #000000\", | |
1897 \"+ c #F3DA00\", | |
1898 \"@ c #F5DF00\", | |
1899 \"# c #F7E300\", | |
1900 \"$ c #F9E700\", | |
1901 \"% c #FAEA00\", | |
1902 \"& c #FBEC00\", | |
1903 \"* c #FBED00\", | |
1904 \"= c #FCEE00\", | |
1905 \"- c #FAEB00\", | |
1906 \"; c #F9E800\", | |
1907 \"> c #F8E500\", | |
1908 \", c #F6E000\", | |
1909 \"' c #F4DB00\", | |
1910 \") c #F1D500\", | |
1911 \"! c #EFD000\", | |
1912 \"~ c #B7CA00\", | |
1913 \"{ c #BFD100\", | |
1914 \"] c #C5D700\", | |
1915 \"^ c #CBDB00\", | |
1916 \"/ c #CFDF00\", | |
1917 \"( c #D2E200\", | |
1918 \"_ c #D4E400\", | |
1919 \": c #D3E300\", | |
1920 \"< c #D0E000\", | |
1921 \"[ c #CCDD00\", | |
1922 \"} c #C7D800\", | |
1923 \"| c #C1D300\", | |
1924 \"1 c #BACC00\", | |
1925 \"2 c #B1C500\", | |
1926 \"3 c #A8BC00\", | |
1927 \"4 c #20A900\", | |
1928 \"5 c #22AF00\", | |
1929 \"6 c #24B500\", | |
1930 \"7 c #26B900\", | |
1931 \"8 c #27BC00\", | |
1932 \"9 c #27BE00\", | |
1933 \"0 c #28BF00\", | |
1934 \"a c #27BD00\", | |
1935 \"b c #26BA00\", | |
1936 \"c c #25B600\", | |
1937 \"d c #23B100\", | |
1938 \"e c #21AB00\", | |
1939 \"f c #1FA400\", | |
1940 \"g c #1C9B00\", | |
1941 \"h c #21AA00\", | |
1942 \"i c #24B300\", | |
1943 \"j c #25B800\", | |
1944 \"k c #25B700\", | |
1945 \"l c #24B400\", | |
1946 \"m c #23B000\", | |
1947 \"n c #1FA500\", | |
1948 \"o c #1D9E00\", | |
1949 \"p c #20A800\", | |
1950 \"q c #21AC00\", | |
1951 \"r c #23B200\", | |
1952 \"s c #22AD00\", | |
1953 \"t c #1D9F00\", | |
1954 \"u c #20A700\", | |
1955 \"v c #1EA100\", | |
1956 \"w c #1C9C00\", | |
1957 \"x c #1DA000\", | |
1958 \"y c #1B9800\", | |
1959 \"z c #1A9600\", | |
1960 \"A c #1A9700\", | |
1961 \"B c #1A9500\", | |
1962 \"C c #199200\", | |
1963 \"D c #189100\", | |
1964 \"E c #178C00\", | |
1965 \" \", | |
1966 \" \", | |
1967 \" \", | |
1968 \" \", | |
1969 \" ................... \", | |
1970 \" .+@#$%&*=*&-;>,')!. \", | |
1971 \" ................... \", | |
1972 \" \", | |
1973 \" ................... \", | |
1974 \" .~{]^/(___:<[}|123. \", | |
1975 \" ................... \", | |
1976 \" \", | |
1977 \" ................... \", | |
1978 \" .45678909abcdefg. \", | |
1979 \" .h5icj7jklmeno. \", | |
1980 \" .pq5drrmshft. \", | |
1981 \" .fu4h4pnvw. \", | |
1982 \" .oxvxtwy. \", | |
1983 \" .zAAzB. \", | |
1984 \" .CCD. \", | |
1985 \" .E. \", | |
1986 \" . \", | |
1987 \" \", | |
1988 \" \"}; | |
1989 " | |
1990 'xpm t) | |
1991 "Image for the next feed button.")) | |
1992 | |
1993 | |
1994 (defconst newsticker--update-image | |
1995 (if (fboundp 'create-image) | |
1996 (create-image "/* XPM */ | |
1997 static char * update_xpm[] = { | |
1998 \"24 24 37 1\", | |
1999 \" c None\", | |
2000 \". c #076D00\", | |
2001 \"+ c #0A8600\", | |
2002 \"@ c #0A8800\", | |
2003 \"# c #098400\", | |
2004 \"$ c #087200\", | |
2005 \"% c #087900\", | |
2006 \"& c #098500\", | |
2007 \"* c #098100\", | |
2008 \"= c #087600\", | |
2009 \"- c #097E00\", | |
2010 \"; c #097F00\", | |
2011 \"> c #0A8700\", | |
2012 \", c #0A8C00\", | |
2013 \"' c #097C00\", | |
2014 \") c #098300\", | |
2015 \"! c #0A8900\", | |
2016 \"~ c #0A8E00\", | |
2017 \"{ c #0B9200\", | |
2018 \"] c #087700\", | |
2019 \"^ c #076E00\", | |
2020 \"/ c #076C00\", | |
2021 \"( c #076B00\", | |
2022 \"_ c #076A00\", | |
2023 \": c #076900\", | |
2024 \"< c #076800\", | |
2025 \"[ c #066700\", | |
2026 \"} c #066500\", | |
2027 \"| c #066400\", | |
2028 \"1 c #066300\", | |
2029 \"2 c #066600\", | |
2030 \"3 c #066200\", | |
2031 \"4 c #076700\", | |
2032 \"5 c #065E00\", | |
2033 \"6 c #066100\", | |
2034 \"7 c #065F00\", | |
2035 \"8 c #066000\", | |
2036 \" \", | |
2037 \" \", | |
2038 \" \", | |
2039 \" . +@@@+# \", | |
2040 \" $% &@ +* \", | |
2041 \" =-# ; \", | |
2042 \" %*>, ' \", | |
2043 \" ')!~{ = \", | |
2044 \" ]$ \", | |
2045 \" ^ ^ \", | |
2046 \" . . \", | |
2047 \" / ( \", | |
2048 \" _ : \", | |
2049 \" < [ \", | |
2050 \" } | \", | |
2051 \" [[ \", | |
2052 \" 1 $.:23 \", | |
2053 \" 3 4}35 \", | |
2054 \" 6 655 \", | |
2055 \" 76 85 55 \", | |
2056 \" 5555555 5 \", | |
2057 \" \", | |
2058 \" \", | |
2059 \" \"}; | |
2060 " | |
2061 'xpm t) | |
2062 "Image for the update button.")) | |
2063 | |
2064 (defconst newsticker--browse-image | |
2065 (if (fboundp 'create-image) | |
2066 (create-image "/* XPM */ | |
2067 static char * visit_xpm[] = { | |
2068 \"24 24 39 1\", | |
2069 \" c None\", | |
2070 \". c #000000\", | |
2071 \"+ c #FFFFFF\", | |
2072 \"@ c #00E63D\", | |
2073 \"# c #00E83E\", | |
2074 \"$ c #00E73D\", | |
2075 \"% c #00E93E\", | |
2076 \"& c #00E63C\", | |
2077 \"* c #00E53C\", | |
2078 \"= c #00E23B\", | |
2079 \"- c #00E33B\", | |
2080 \"; c #00E83D\", | |
2081 \"> c #00E13A\", | |
2082 \", c #00DD38\", | |
2083 \"' c #00DE38\", | |
2084 \") c #00E23A\", | |
2085 \"! c #00E43C\", | |
2086 \"~ c #00DF39\", | |
2087 \"{ c #00DB37\", | |
2088 \"] c #00D634\", | |
2089 \"^ c #00D734\", | |
2090 \"/ c #00E039\", | |
2091 \"( c #00DC37\", | |
2092 \"_ c #00D835\", | |
2093 \": c #00D332\", | |
2094 \"< c #00CD2F\", | |
2095 \"[ c #00DB36\", | |
2096 \"} c #00D433\", | |
2097 \"| c #00CF30\", | |
2098 \"1 c #00DA36\", | |
2099 \"2 c #00D936\", | |
2100 \"3 c #00D533\", | |
2101 \"4 c #00D131\", | |
2102 \"5 c #00CE2F\", | |
2103 \"6 c #00CC2F\", | |
2104 \"7 c #00CA2D\", | |
2105 \"8 c #00C62B\", | |
2106 \"9 c #00C52A\", | |
2107 \"0 c #00BE27\", | |
2108 \" \", | |
2109 \" \", | |
2110 \" . \", | |
2111 \" .+. \", | |
2112 \" .+++. \", | |
2113 \" .++.++. \", | |
2114 \" .++.@.++. \", | |
2115 \" .++.##$.++. \", | |
2116 \" .++.%%%#&.++. \", | |
2117 \" .++.$%%%#*=.++. \", | |
2118 \" .++.-@;##$*>,.++. \", | |
2119 \" .++.')!&@@*=~{].++. \", | |
2120 \" .++.^{~>---)/(_:<.++. \", | |
2121 \" .++.^[,~/~'(_}|.++. \", | |
2122 \" .++.]_1[12^:|.++. \", | |
2123 \" .++.:}33:45.++. \", | |
2124 \" .++.<5567.++. \", | |
2125 \" .++.889.++. \", | |
2126 \" .++.0.++. \", | |
2127 \" .++.++. \", | |
2128 \" .+++. \", | |
2129 \" .+. \", | |
2130 \" . \", | |
2131 \" \"}; | |
2132 " | |
2133 'xpm t) | |
2134 "Image for the browse button.")) | |
2135 | |
2136 | |
2137 (defvar newsticker-tool-bar-map | |
2138 (if (featurep 'xemacs) | |
2139 nil | |
2140 (let ((tool-bar-map (make-sparse-keymap))) | |
2141 (define-key tool-bar-map [newsticker-sep-1] | |
2142 (list 'menu-item "--double-line")) | |
2143 (define-key tool-bar-map [newsticker-browse-url] | |
2144 (list 'menu-item "newsticker-browse-url" 'newsticker-browse-url | |
2145 :visible t | |
2146 :help "Browse URL for item at point" | |
2147 :image newsticker--browse-image)) | |
2148 (define-key tool-bar-map [newsticker-buffer-force-update] | |
2149 (list 'menu-item "newsticker-buffer-force-update" | |
2150 'newsticker-buffer-force-update | |
2151 :visible t | |
2152 :help "Update newsticker buffer" | |
2153 :image newsticker--update-image | |
2154 :enable '(not newsticker--buffer-uptodate-p))) | |
2155 (define-key tool-bar-map [newsticker-get-all-news] | |
2156 (list 'menu-item "newsticker-get-all-news" 'newsticker-get-all-news | |
2157 :visible t | |
2158 :help "Get news for all feeds" | |
2159 :image newsticker--get-all-image)) | |
2160 (define-key tool-bar-map [newsticker-mark-item-at-point-as-read] | |
2161 (list 'menu-item "newsticker-mark-item-at-point-as-read" | |
2162 'newsticker-mark-item-at-point-as-read | |
2163 :visible t | |
2164 :image newsticker--mark-read-image | |
2165 :help "Mark current item as read" | |
2166 :enable '(newsticker-item-not-old-p))) | |
2167 (define-key tool-bar-map [newsticker-mark-item-at-point-as-immortal] | |
2168 (list 'menu-item "newsticker-mark-item-at-point-as-immortal" | |
2169 'newsticker-mark-item-at-point-as-immortal | |
2170 :visible t | |
2171 :image newsticker--mark-immortal-image | |
2172 :help "Mark current item as immortal" | |
2173 :enable '(newsticker-item-not-immortal-p))) | |
2174 (define-key tool-bar-map [newsticker-toggle-auto-narrow-to-feed] | |
2175 (list 'menu-item "newsticker-toggle-auto-narrow-to-feed" | |
2176 'newsticker-toggle-auto-narrow-to-feed | |
2177 :visible t | |
2178 :help "Toggle visibility of other feeds" | |
2179 :image newsticker--narrow-image)) | |
2180 (define-key tool-bar-map [newsticker-next-feed] | |
2181 (list 'menu-item "newsticker-next-feed" 'newsticker-next-feed | |
2182 :visible t | |
2183 :help "Go to next feed" | |
2184 :image newsticker--next-feed-image | |
2185 :enable '(newsticker-next-feed-available-p))) | |
2186 (define-key tool-bar-map [newsticker-next-item] | |
2187 (list 'menu-item "newsticker-next-item" 'newsticker-next-item | |
2188 :visible t | |
2189 :help "Go to next item" | |
2190 :image newsticker--next-item-image | |
2191 :enable '(newsticker-next-item-available-p))) | |
2192 (define-key tool-bar-map [newsticker-previous-item] | |
2193 (list 'menu-item "newsticker-previous-item" 'newsticker-previous-item | |
2194 :visible t | |
2195 :help "Go to previous item" | |
2196 :image newsticker--previous-item-image | |
2197 :enable '(newsticker-previous-item-available-p))) | |
2198 (define-key tool-bar-map [newsticker-previous-feed] | |
2199 (list 'menu-item "newsticker-previous-feed" 'newsticker-previous-feed | |
2200 :visible t | |
2201 :help "Go to previous feed" | |
2202 :image newsticker--previous-feed-image | |
2203 :enable '(newsticker-previous-feed-available-p))) | |
2204 ;; standard icons / actions | |
2205 (tool-bar-add-item "close" | |
2206 'newsticker-close-buffer | |
2207 'newsticker-close-buffer | |
2208 :help "Close newsticker buffer") | |
2209 (tool-bar-add-item "preferences" | |
2210 'newsticker-customize | |
2211 'newsticker-customize | |
2212 :help "Customize newsticker") | |
2213 tool-bar-map))) | |
2214 | |
2215 ;; ====================================================================== | |
2216 ;;; Newsticker mode | |
2217 ;; ====================================================================== | |
2218 | |
2219 (define-derived-mode newsticker-mode fundamental-mode | |
2220 "NewsTicker" | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2221 "Viewing news feeds in Emacs." |
65468 | 2222 (set (make-local-variable 'tool-bar-map) newsticker-tool-bar-map) |
2223 (set (make-local-variable 'imenu-sort-function) nil) | |
2224 (set (make-local-variable 'scroll-conservatively) 999) | |
2225 (setq imenu-create-index-function 'newsticker--imenu-create-index) | |
2226 (setq imenu-default-goto-function 'newsticker--imenu-goto) | |
2227 (setq buffer-read-only t) | |
2228 (auto-fill-mode -1) ;; turn auto-fill off! | |
2229 (font-lock-mode -1) ;; turn off font-lock!! | |
2230 (set (make-local-variable 'font-lock-defaults) nil) | |
2231 (set (make-local-variable 'line-move-ignore-invisible) t) | |
2232 (setq mode-line-format | |
2233 (list "-" | |
2234 'mode-line-mule-info | |
2235 'mode-line-modified | |
2236 'mode-line-frame-identification | |
2237 " Newsticker (" | |
2238 '(newsticker--buffer-uptodate-p | |
2239 "up to date" | |
2240 "NEED UPDATE") | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2241 ") " |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2242 '(:eval (format "[%d]" (length newsticker--process-ids))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2243 " -- " |
65468 | 2244 '(:eval (newsticker--buffer-get-feed-title-at-point)) |
2245 ": " | |
2246 '(:eval (newsticker--buffer-get-item-title-at-point)) | |
2247 " %-")) | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2248 (add-to-invisibility-spec 't) |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2249 (unless newsticker-show-all-news-elements |
65468 | 2250 (add-to-invisibility-spec 'extra)) |
2251 (newsticker--buffer-set-uptodate nil)) | |
2252 | |
2253 ;; refine its mode-map | |
2254 (define-key newsticker-mode-map "sO" 'newsticker-show-old-items) | |
2255 (define-key newsticker-mode-map "hO" 'newsticker-hide-old-items) | |
2256 (define-key newsticker-mode-map "sa" 'newsticker-show-all-desc) | |
2257 (define-key newsticker-mode-map "ha" 'newsticker-hide-all-desc) | |
2258 (define-key newsticker-mode-map "sf" 'newsticker-show-feed-desc) | |
2259 (define-key newsticker-mode-map "hf" 'newsticker-hide-feed-desc) | |
2260 (define-key newsticker-mode-map "so" 'newsticker-show-old-item-desc) | |
2261 (define-key newsticker-mode-map "ho" 'newsticker-hide-old-item-desc) | |
2262 (define-key newsticker-mode-map "sn" 'newsticker-show-new-item-desc) | |
2263 (define-key newsticker-mode-map "hn" 'newsticker-hide-new-item-desc) | |
2264 (define-key newsticker-mode-map "se" 'newsticker-show-entry) | |
2265 (define-key newsticker-mode-map "he" 'newsticker-hide-entry) | |
2266 (define-key newsticker-mode-map "sx" 'newsticker-show-extra) | |
2267 (define-key newsticker-mode-map "hx" 'newsticker-hide-extra) | |
2268 | |
2269 (define-key newsticker-mode-map " " 'scroll-up) | |
2270 (define-key newsticker-mode-map "q" 'newsticker-close-buffer) | |
2271 (define-key newsticker-mode-map "p" 'newsticker-previous-item) | |
2272 (define-key newsticker-mode-map "P" 'newsticker-previous-new-item) | |
2273 (define-key newsticker-mode-map "F" 'newsticker-previous-feed) | |
2274 (define-key newsticker-mode-map "\t" 'newsticker-next-item) | |
2275 (define-key newsticker-mode-map "n" 'newsticker-next-item) | |
2276 (define-key newsticker-mode-map "N" 'newsticker-next-new-item) | |
2277 (define-key newsticker-mode-map "f" 'newsticker-next-feed) | |
2278 (define-key newsticker-mode-map "M" 'newsticker-mark-all-items-as-read) | |
2279 (define-key newsticker-mode-map "m" | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2280 'newsticker-mark-all-items-at-point-as-read-and-redraw) |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2281 (define-key newsticker-mode-map "o" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2282 'newsticker-mark-item-at-point-as-read) |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2283 (define-key newsticker-mode-map "O" |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2284 'newsticker-mark-all-items-at-point-as-read) |
65468 | 2285 (define-key newsticker-mode-map "G" 'newsticker-get-all-news) |
2286 (define-key newsticker-mode-map "g" 'newsticker-get-news-at-point) | |
2287 (define-key newsticker-mode-map "u" 'newsticker-buffer-update) | |
2288 (define-key newsticker-mode-map "U" 'newsticker-buffer-force-update) | |
2289 (define-key newsticker-mode-map "a" 'newsticker-add-url) | |
2290 | |
2291 (define-key newsticker-mode-map "i" | |
2292 'newsticker-mark-item-at-point-as-immortal) | |
2293 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2294 (define-key newsticker-mode-map "xf" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2295 'newsticker-toggle-auto-narrow-to-feed) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2296 (define-key newsticker-mode-map "xi" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2297 'newsticker-toggle-auto-narrow-to-item) |
65468 | 2298 |
2299 ;; maps for the clickable portions | |
2300 (defvar newsticker--url-keymap (make-sparse-keymap) | |
2301 "Key map for click-able headings in the newsticker buffer.") | |
2302 (define-key newsticker--url-keymap [mouse-2] | |
2303 'newsticker-mouse-browse-url) | |
2304 (define-key newsticker--url-keymap "\n" | |
2305 'newsticker-browse-url) | |
2306 (define-key newsticker--url-keymap "\C-m" | |
2307 'newsticker-browse-url) | |
2308 (define-key newsticker--url-keymap [(control return)] | |
2309 'newsticker-handle-url) | |
2310 | |
2311 ;; newsticker menu | |
2312 (defvar newsticker-menu (make-sparse-keymap "Newsticker")) | |
2313 | |
2314 (define-key newsticker-menu [newsticker-browse-url] | |
2315 '("Browse URL for item at point" . newsticker-browse-url)) | |
2316 (define-key newsticker-menu [newsticker-separator-1] | |
2317 '("--")) | |
2318 (define-key newsticker-menu [newsticker-buffer-update] | |
2319 '("Update buffer" . newsticker-buffer-update)) | |
2320 (define-key newsticker-menu [newsticker-separator-2] | |
2321 '("--")) | |
2322 (define-key newsticker-menu [newsticker-get-all-news] | |
2323 '("Get news from all feeds" . newsticker-get-all-news)) | |
2324 (define-key newsticker-menu [newsticker-get-news-at-point] | |
2325 '("Get news from feed at point" . newsticker-get-news-at-point)) | |
2326 (define-key newsticker-menu [newsticker-separator-3] | |
2327 '("--")) | |
2328 (define-key newsticker-menu [newsticker-mark-all-items-as-read] | |
2329 '("Mark all items as read" . newsticker-mark-all-items-as-read)) | |
2330 (define-key newsticker-menu [newsticker-mark-all-items-at-point-as-read] | |
2331 '("Mark all items in feed at point as read" . | |
2332 newsticker-mark-all-items-at-point-as-read)) | |
2333 (define-key newsticker-menu [newsticker-mark-item-at-point-as-read] | |
2334 '("Mark item at point as read" . | |
2335 newsticker-mark-item-at-point-as-read)) | |
2336 (define-key newsticker-menu [newsticker-mark-item-at-point-as-immortal] | |
2337 '("Toggle immortality for item at point" . | |
2338 newsticker-mark-item-at-point-as-immortal)) | |
2339 (define-key newsticker-menu [newsticker-separator-4] | |
2340 '("--")) | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2341 (define-key newsticker-menu [newsticker-toggle-auto-narrow-to-item] |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2342 '("Narrow to single item" . newsticker-toggle-auto-narrow-to-item)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2343 (define-key newsticker-menu [newsticker-toggle-auto-narrow-to-feed] |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2344 '("Narrow to single news feed" . newsticker-toggle-auto-narrow-to-feed)) |
65468 | 2345 (define-key newsticker-menu [newsticker-hide-old-items] |
2346 '("Hide old items" . newsticker-hide-old-items)) | |
2347 (define-key newsticker-menu [newsticker-show-old-items] | |
2348 '("Show old items" . newsticker-show-old-items)) | |
2349 (define-key newsticker-menu [newsticker-next-item] | |
2350 '("Go to next item" . newsticker-next-item)) | |
2351 (define-key newsticker-menu [newsticker-previous-item] | |
2352 '("Go to previous item" . newsticker-previous-item)) | |
2353 | |
2354 ;; bind menu to mouse | |
2355 (define-key newsticker-mode-map [down-mouse-3] newsticker-menu) | |
2356 ;; Put menu in menu-bar | |
2357 (define-key newsticker-mode-map [menu-bar Newsticker] | |
2358 (cons "Newsticker" newsticker-menu)) | |
2359 | |
2360 | |
2361 ;; ====================================================================== | |
2362 ;;; shortcuts | |
2363 ;; ====================================================================== | |
2364 (defsubst newsticker--title (item) | |
2365 "Return title of ITEM." | |
2366 (nth 0 item)) | |
2367 (defsubst newsticker--desc (item) | |
2368 "Return description of ITEM." | |
2369 (nth 1 item)) | |
2370 (defsubst newsticker--link (item) | |
2371 "Return link of ITEM." | |
2372 (nth 2 item)) | |
2373 (defsubst newsticker--time (item) | |
2374 "Return time of ITEM." | |
2375 (nth 3 item)) | |
2376 (defsubst newsticker--age (item) | |
2377 "Return age of ITEM." | |
2378 (nth 4 item)) | |
2379 (defsubst newsticker--pos (item) | |
2380 "Return position/index of ITEM." | |
2381 (nth 5 item)) | |
2382 (defsubst newsticker--preformatted-contents (item) | |
2383 "Return pre-formatted text of ITEM." | |
2384 (nth 6 item)) | |
2385 (defsubst newsticker--preformatted-title (item) | |
2386 "Return pre-formatted title of ITEM." | |
2387 (nth 7 item)) | |
2388 (defsubst newsticker--extra (item) | |
2389 "Return extra attributes of ITEM." | |
2390 (nth 8 item)) | |
2391 (defsubst newsticker--guid (item) | |
2392 "Return guid of ITEM." | |
2393 (let ((guid (assoc 'guid (newsticker--extra item)))) | |
2394 (if (stringp guid) | |
2395 guid | |
2396 (car (xml-node-children guid))))) | |
2397 (defsubst newsticker--enclosure (item) | |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
2398 "Return enclosure element of ITEM in the form \(...FIXME...\) or nil." |
65468 | 2399 (let ((enclosure (assoc 'enclosure (newsticker--extra item)))) |
2400 (if enclosure | |
2401 (xml-node-attributes enclosure)))) | |
2402 | |
2403 ;; ====================================================================== | |
2404 ;;; User fun | |
2405 ;; ====================================================================== | |
2406 | |
65998
e6b90c8b34d8
(newsticker-start, newsticker-show-news): Add autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents:
65638
diff
changeset
|
2407 ;;;###autoload |
65468 | 2408 (defun newsticker-start (&optional do-not-complain-if-running) |
2409 "Start the newsticker. | |
2410 Start the timers for display and retrieval. If the newsticker, i.e. the | |
2411 timers, are running already a warning message is printed unless | |
2412 DO-NOT-COMPLAIN-IF-RUNNING is not nil. | |
2413 Run `newsticker-start-hook' if newsticker was not running already." | |
2414 (interactive) | |
2415 (let ((running (newsticker-running-p))) | |
2416 ;; read old cache if it exists and newsticker is not running | |
2417 (unless running | |
2418 (let* ((coding-system-for-read 'utf-8) | |
2419 (buf (find-file-noselect newsticker-cache-filename))) | |
2420 (when buf | |
2421 (set-buffer buf) | |
2422 (goto-char (point-min)) | |
2423 (condition-case nil | |
2424 (setq newsticker--cache (read buf)) | |
2425 (error | |
2426 (message "Error while reading newsticker cache file!") | |
2427 (setq newsticker--cache nil)))))) | |
2428 ;; start retrieval timers -- for sake of simplicity we will start | |
2429 ;; one timer for each feed | |
2430 (mapc (lambda (item) | |
2431 (let* ((feed-name (car item)) | |
2432 (start-time (nth 2 item)) | |
2433 (interval (or (nth 3 item) | |
2434 newsticker-retrieval-interval)) | |
2435 (timer (assoc (car item) | |
2436 newsticker--retrieval-timer-list))) | |
2437 (if timer | |
2438 (or do-not-complain-if-running | |
2439 (message "Timer for %s is running already!" | |
2440 feed-name)) | |
2441 (newsticker--debug-msg "Starting timer for %s: %s, %d" | |
2442 feed-name start-time interval) | |
2443 ;; do not repeat retrieval if interval not positive | |
2444 (if (<= interval 0) | |
2445 (setq interval nil)) | |
2446 ;; Suddenly XEmacs doesn't like start-time 0 | |
2447 (if (or (not start-time) | |
2448 (and (numberp start-time) (= start-time 0))) | |
2449 (setq start-time 1)) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2450 ;; (message "start-time %s" start-time) |
65468 | 2451 (setq timer (run-at-time start-time interval |
2452 'newsticker-get-news feed-name)) | |
2453 (if interval | |
2454 (add-to-list 'newsticker--retrieval-timer-list | |
2455 (cons feed-name timer)))))) | |
2456 (append newsticker-url-list-defaults newsticker-url-list)) | |
2457 (unless running | |
2458 (run-hooks 'newsticker-start-hook) | |
2459 (message "Newsticker started!")))) | |
2460 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2461 ;;;###autoload |
65468 | 2462 (defun newsticker-start-ticker () |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2463 "Start newsticker's ticker (but not the news retrieval). |
65468 | 2464 Start display timer for the actual ticker if wanted and not |
2465 running already." | |
2466 (interactive) | |
2467 (if (and (> newsticker-display-interval 0) | |
2468 (not newsticker--display-timer)) | |
2469 (setq newsticker--display-timer | |
2470 (run-at-time newsticker-display-interval | |
2471 newsticker-display-interval | |
2472 'newsticker--display-tick)))) | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
2473 |
65468 | 2474 (defun newsticker-stop () |
2475 "Stop the newsticker and the newsticker-ticker. | |
2476 Cancel the timers for display and retrieval. Run `newsticker-stop-hook' | |
2477 if newsticker has been running." | |
2478 (interactive) | |
2479 (newsticker--cache-update t) | |
2480 (newsticker-stop-ticker) | |
2481 (when (newsticker-running-p) | |
2482 (mapc (lambda (name-and-timer) | |
2483 (cancel-timer (cdr name-and-timer))) | |
2484 newsticker--retrieval-timer-list) | |
2485 (setq newsticker--retrieval-timer-list nil) | |
2486 (run-hooks 'newsticker-stop-hook) | |
2487 (message "Newsticker stopped!"))) | |
2488 | |
2489 (defun newsticker-stop-ticker () | |
2490 "Stop newsticker's ticker (but not the news retrieval)." | |
2491 (interactive) | |
2492 (when newsticker--display-timer | |
2493 (cancel-timer newsticker--display-timer) | |
2494 (setq newsticker--display-timer nil))) | |
2495 | |
2496 ;; the functions we need for retrieval and display | |
65998
e6b90c8b34d8
(newsticker-start, newsticker-show-news): Add autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents:
65638
diff
changeset
|
2497 ;;;###autoload |
65468 | 2498 (defun newsticker-show-news () |
2499 "Switch to newsticker buffer. You may want to bind this to a key." | |
2500 (interactive) | |
2501 (newsticker-start t) ;; will start only if not running | |
2502 (newsticker-buffer-update) | |
2503 (switch-to-buffer "*newsticker*")) | |
2504 | |
2505 (defun newsticker-buffer-force-update () | |
2506 "Update the newsticker buffer, even if not necessary." | |
2507 (interactive) | |
2508 (newsticker-buffer-update t)) | |
2509 | |
2510 (defun newsticker-buffer-update (&optional force) | |
2511 "Update the *newsticker* buffer. | |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
2512 Unless FORCE is t this is done only if necessary, i.e. when the |
65468 | 2513 *newsticker* buffer is not up-to-date." |
2514 (interactive) | |
2515 ;; bring cache data into proper order.... | |
2516 (newsticker--cache-sort) | |
2517 ;; fill buffer | |
2518 (save-excursion | |
2519 (let ((buf (get-buffer "*newsticker*"))) | |
2520 (if buf | |
2521 (switch-to-buffer buf) | |
2522 (switch-to-buffer (get-buffer-create "*newsticker*")) | |
2523 (newsticker--buffer-set-uptodate nil))) | |
2524 (when (or force | |
2525 (not newsticker--buffer-uptodate-p)) | |
2526 (message "Preparing newsticker buffer...") | |
2527 (setq buffer-undo-list t) | |
2528 (let ((inhibit-read-only t)) | |
2529 (set-buffer-modified-p nil) | |
2530 (erase-buffer) | |
2531 (newsticker-mode) | |
2532 ;; Emacs 21.3.50 does not care if we turn off auto-fill in the | |
2533 ;; definition of newsticker-mode, so we do it here (again) | |
2534 (auto-fill-mode -1) | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
2535 |
65468 | 2536 (set-buffer-file-coding-system 'utf-8) |
2537 | |
2538 (if newsticker-use-full-width | |
2539 (set (make-local-variable 'fill-column) (1- (window-width)))) | |
2540 (newsticker--buffer-insert-all-items) | |
2541 | |
2542 ;; FIXME: needed for methods buffer in ecb | |
2543 ;; (set-visited-file-name "*newsticker*") | |
2544 | |
2545 (set-buffer-modified-p nil) | |
2546 (newsticker-hide-all-desc) | |
2547 (if newsticker-hide-old-items-in-newsticker-buffer | |
2548 (newsticker-hide-old-items)) | |
2549 (if newsticker-show-descriptions-of-new-items | |
2550 (newsticker-show-new-item-desc)) | |
2551 ) | |
2552 (message "")) | |
2553 (newsticker--buffer-set-uptodate t) | |
2554 (run-hooks 'newsticker-buffer-change-hook))) | |
2555 | |
2556 (defun newsticker-get-all-news () | |
2557 "Launch retrieval of news from all configured newsticker sites. | |
2558 This does NOT start the retrieval timers." | |
2559 (interactive) | |
2560 ;; launch retrieval of news | |
2561 (mapc (lambda (item) | |
2562 (newsticker-get-news (car item))) | |
2563 (append newsticker-url-list-defaults newsticker-url-list))) | |
2564 | |
2565 (defun newsticker-get-news-at-point () | |
2566 "Launch retrieval of news for the feed point is in. | |
2567 This does NOT start the retrieval timers." | |
2568 (interactive) | |
2569 ;; launch retrieval of news | |
2570 (let ((feed (get-text-property (point) 'feed))) | |
2571 (when feed | |
2572 (newsticker--debug-msg "Getting news for %s" (symbol-name feed)) | |
2573 (newsticker-get-news (symbol-name feed))))) | |
2574 | |
2575 (defun newsticker-add-url (url name) | |
2576 "Add given URL under given NAME to `newsticker-url-list'. | |
2577 If URL is nil it is searched at point." | |
2578 (interactive | |
2579 (list | |
2580 (read-string "URL: " | |
2581 (save-excursion | |
2582 (end-of-line) | |
2583 (and | |
2584 (re-search-backward | |
2585 "http://" | |
2586 (if (> (point) (+ (point-min) 100)) | |
2587 (- (point) 100) | |
2588 (point-min)) | |
2589 t) | |
2590 (re-search-forward | |
2591 "http://[-a-zA-Z0-9&/_.]*" | |
2592 (if (< (point) (- (point-max) 200)) | |
2593 (+ (point) 200) | |
2594 (point-max)) | |
2595 t) | |
2596 (buffer-substring-no-properties (match-beginning 0) | |
2597 (match-end 0))))) | |
2598 (read-string "Name: "))) | |
2599 (add-to-list 'newsticker-url-list (list name url nil nil nil) t) | |
2600 (customize-variable 'newsticker-url-list)) | |
2601 | |
2602 (defun newsticker-w3m-show-inline-images () | |
2603 "Show inline images in visible text ranges. | |
2604 In-line images in invisible text ranges are hidden. This function | |
2605 calls `w3m-toggle-inline-image'. It works only if | |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
2606 `newsticker-html-renderer' is set to `w3m-region'." |
65468 | 2607 (interactive) |
2608 (if (eq newsticker-html-renderer 'w3m-region) | |
2609 (let ((inhibit-read-only t)) | |
2610 (save-excursion | |
2611 (save-restriction | |
2612 (widen) | |
2613 (goto-char (point-min)) | |
2614 (let ((pos (point))) | |
2615 (while pos | |
2616 (setq pos (next-single-property-change pos 'w3m-image)) | |
2617 (when pos | |
2618 (goto-char pos) | |
2619 (when (get-text-property pos 'w3m-image) | |
2620 (let ((invis (newsticker--lists-intersect-p | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2621 (get-text-property (1- (point)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2622 'invisible) |
65468 | 2623 buffer-invisibility-spec))) |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2624 (unless (car (get-text-property (1- (point)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2625 'display)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2626 (unless invis |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2627 (w3m-toggle-inline-image t))))))))))))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2628 |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2629 (defadvice w3m-insert-image (after newsticker activate) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2630 (newsticker--buffer-after-w3m-insert-image (ad-get-arg 0) (ad-get-arg 1))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2631 |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2632 (defun newsticker--buffer-after-w3m-insert-image (beg end) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2633 "Save preformatted contents after an image has been inserted |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2634 between BEG and END." |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2635 (when (string= (buffer-name) "*newsticker*") |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2636 (save-excursion |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2637 (newsticker--buffer-beginning-of-item) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2638 (let* ((pos (point)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2639 (feed (get-text-property pos 'feed)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2640 (age (get-text-property pos 'nt-age)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2641 (title (get-text-property pos 'nt-title)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2642 (guid (get-text-property pos 'nt-guid)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2643 (nt-desc (get-text-property pos 'nt-desc)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2644 (item (newsticker--cache-contains newsticker--cache |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2645 feed title nt-desc |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2646 nil nil guid)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2647 (desc-beg (newsticker--buffer-goto '(desc))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2648 (desc-end (newsticker--buffer-end-of-item))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2649 ;;(add-text-properties beg end (list nt-type desc)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2650 (add-text-properties beg end (list 'invisible |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2651 (get-text-property end 'invisible))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2652 ;;(message "newsticker--buffer-after-w3m-insert-image at %s, %s: `%s'" |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2653 ;; beg feed title) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2654 (if item |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2655 (newsticker--cache-set-preformatted-contents |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2656 item (buffer-substring desc-beg desc-end)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2657 (message "ooops in newsticker--buffer-after-w3m-insert-image at %s, %s: `%s'" |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2658 beg feed title)))))) |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
2659 |
65468 | 2660 ;; ====================================================================== |
2661 ;;; keymap stuff | |
2662 ;; ====================================================================== | |
2663 (defun newsticker-close-buffer () | |
2664 "Close the newsticker buffer." | |
2665 (interactive) | |
2666 (newsticker--cache-update t) | |
2667 (bury-buffer)) | |
2668 | |
2669 (defun newsticker-next-new-item (&optional do-not-wrap-at-eob) | |
2670 "Go to next new news item. | |
2671 If no new item is found behind point, search is continued at | |
2672 beginning of buffer unless optional argument DO-NOT-WRAP-AT-EOB | |
2673 is non-nil." | |
2674 (interactive) | |
2675 (widen) | |
2676 (let ((go-ahead t)) | |
2677 (while go-ahead | |
2678 (unless (newsticker--buffer-goto '(item) 'new) | |
2679 ;; found nothing -- wrap | |
2680 (unless do-not-wrap-at-eob | |
2681 (goto-char (point-min)) | |
2682 (newsticker-next-new-item t)) | |
2683 (setq go-ahead nil)) | |
2684 (unless (newsticker--lists-intersect-p | |
2685 (get-text-property (point) 'invisible) | |
2686 buffer-invisibility-spec) | |
2687 ;; this item is invisible -- continue search | |
2688 (setq go-ahead nil)))) | |
2689 (run-hooks 'newsticker-select-item-hook) | |
2690 (point)) | |
2691 | |
2692 (defun newsticker-previous-new-item (&optional do-not-wrap-at-bob) | |
2693 "Go to previous new news item. | |
2694 If no new item is found before point, search is continued at | |
2695 beginning of buffer unless optional argument DO-NOT-WRAP-AT-BOB | |
2696 is non-nil." | |
2697 (interactive) | |
2698 (widen) | |
2699 (let ((go-ahead t)) | |
2700 (while go-ahead | |
2701 (unless (newsticker--buffer-goto '(item) 'new t) | |
2702 (unless do-not-wrap-at-bob | |
2703 (goto-char (point-max)) | |
2704 (newsticker--buffer-goto '(item) 'new t))) | |
2705 (unless (newsticker--lists-intersect-p | |
2706 (get-text-property (point) 'invisible) | |
2707 buffer-invisibility-spec) | |
2708 (setq go-ahead nil)))) | |
2709 (run-hooks 'newsticker-select-item-hook) | |
2710 (point)) | |
2711 | |
2712 (defun newsticker-next-item (&optional do-not-wrap-at-eob) | |
2713 "Go to next news item. | |
2714 Return new buffer position. | |
2715 If no item is found below point, search is continued at beginning | |
2716 of buffer unless optional argument DO-NOT-WRAP-AT-EOB is | |
2717 non-nil." | |
2718 (interactive) | |
2719 (widen) | |
2720 (let ((go-ahead t) | |
2721 (search-list '(item))) | |
2722 (if newsticker--auto-narrow-to-item | |
2723 (setq search-list '(item feed))) | |
2724 (while go-ahead | |
2725 (unless (newsticker--buffer-goto search-list) | |
2726 ;; found nothing -- wrap | |
2727 (unless do-not-wrap-at-eob | |
2728 (goto-char (point-min))) | |
2729 (setq go-ahead nil)) | |
2730 (unless (newsticker--lists-intersect-p | |
2731 (get-text-property (point) 'invisible) | |
2732 buffer-invisibility-spec) | |
2733 (setq go-ahead nil)))) | |
2734 (run-hooks 'newsticker-select-item-hook) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2735 (force-mode-line-update) |
65468 | 2736 (point)) |
2737 | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2738 (defun newsticker-next-item-same-feed () |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2739 "Go to next news item in the same feed. |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2740 Return new buffer position. If no item is found below point or if |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2741 auto-narrow-to-item is enabled, nil is returned." |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2742 (interactive) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2743 (if newsticker--auto-narrow-to-item |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2744 nil |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2745 (let ((go-ahead t) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2746 (current-pos (point)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2747 (end-of-feed (save-excursion (newsticker--buffer-end-of-feed)))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2748 (while go-ahead |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2749 (unless (newsticker--buffer-goto '(item)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2750 (setq go-ahead nil)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2751 (unless (newsticker--lists-intersect-p |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2752 (get-text-property (point) 'invisible) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2753 buffer-invisibility-spec) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2754 (setq go-ahead nil))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2755 (if (and (> (point) current-pos) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2756 (< (point) end-of-feed)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2757 (point) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2758 (goto-char current-pos) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2759 nil)))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2760 |
65468 | 2761 (defun newsticker-previous-item (&optional do-not-wrap-at-bob) |
2762 "Go to previous news item. | |
2763 Return new buffer position. | |
2764 If no item is found before point, search is continued at | |
2765 beginning of buffer unless optional argument DO-NOT-WRAP-AT-BOB | |
2766 is non-nil." | |
2767 (interactive) | |
2768 (widen) | |
2769 (let ((go-ahead t) | |
2770 (search-list '(item))) | |
2771 (if newsticker--auto-narrow-to-item | |
2772 (setq search-list '(item feed))) | |
2773 (when (bobp) | |
2774 (unless do-not-wrap-at-bob | |
2775 (goto-char (point-max)))) | |
2776 (while go-ahead | |
2777 (if (newsticker--buffer-goto search-list nil t) | |
2778 (unless (newsticker--lists-intersect-p | |
2779 (get-text-property (point) 'invisible) | |
2780 buffer-invisibility-spec) | |
2781 (setq go-ahead nil)) | |
2782 (goto-char (point-min)) | |
2783 (setq go-ahead nil)))) | |
2784 (run-hooks 'newsticker-select-item-hook) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2785 (force-mode-line-update) |
65468 | 2786 (point)) |
2787 | |
2788 (defun newsticker-next-feed () | |
2789 "Go to next news feed. | |
2790 Return new buffer position." | |
2791 (interactive) | |
2792 (widen) | |
2793 (newsticker--buffer-goto '(feed)) | |
2794 (run-hooks 'newsticker-select-feed-hook) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2795 (force-mode-line-update) |
65468 | 2796 (point)) |
2797 | |
2798 (defun newsticker-previous-feed () | |
2799 "Go to previous news feed. | |
2800 Return new buffer position." | |
2801 (interactive) | |
2802 (widen) | |
2803 (newsticker--buffer-goto '(feed) nil t) | |
2804 (run-hooks 'newsticker-select-feed-hook) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2805 (force-mode-line-update) |
65468 | 2806 (point)) |
2807 | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2808 (defun newsticker-mark-all-items-at-point-as-read-and-redraw () |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2809 "Mark all items as read and clear ticker contents." |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2810 (interactive) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2811 (when (or newsticker--buffer-uptodate-p |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2812 (y-or-n-p |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2813 "Buffer is not up to date -- really mark items as read? ")) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2814 (newsticker-mark-all-items-of-feed-as-read |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2815 (get-text-property (point) 'feed)))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2816 |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2817 (defun newsticker-mark-all-items-of-feed-as-read (feed) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2818 "Mark all items as read, clear ticker, and redraw *newsticker* buffer." |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2819 (when feed |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2820 (let ((pos (point))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2821 (message "Marking all items as read for %s" (symbol-name feed)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2822 (newsticker--cache-replace-age newsticker--cache feed 'new 'old) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2823 (newsticker--cache-replace-age newsticker--cache feed 'obsolete |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2824 'old) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2825 (newsticker--cache-update) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2826 (newsticker--buffer-set-uptodate nil) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2827 (newsticker--ticker-text-setup) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2828 (newsticker-buffer-update) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2829 ;; go back to where we came frome |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2830 (goto-char pos) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2831 (end-of-line) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2832 (newsticker--buffer-goto '(feed) nil t)))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2833 |
65468 | 2834 (defun newsticker-mark-all-items-at-point-as-read () |
2835 "Mark all items as read and clear ticker contents." | |
2836 (interactive) | |
2837 (when (or newsticker--buffer-uptodate-p | |
2838 (y-or-n-p | |
2839 "Buffer is not up to date -- really mark items as read? ")) | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2840 (newsticker--do-mark-item-at-point-as-read t) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2841 (while (newsticker-next-item-same-feed) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2842 (newsticker--do-mark-item-at-point-as-read t)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2843 (newsticker-next-item t))) |
65468 | 2844 |
2845 (defun newsticker-mark-item-at-point-as-read (&optional respect-immortality) | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2846 "Mark item at point as read and move to next item. |
65468 | 2847 If optional argument RESPECT-IMMORTALITY is not nil immortal items do |
2848 not get changed." | |
2849 (interactive) | |
2850 (when (or newsticker--buffer-uptodate-p | |
2851 (y-or-n-p | |
2852 "Buffer is not up to date -- really mark this item as read? ")) | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2853 (newsticker--do-mark-item-at-point-as-read respect-immortality) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2854 ;; move forward |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2855 (newsticker-next-item t))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2856 |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2857 (defun newsticker--do-mark-item-at-point-as-read (&optional respect-immortality) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2858 "Mark item at point as read. |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2859 If optional argument RESPECT-IMMORTALITY is not nil immortal items do |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2860 not get changed." |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2861 (let ((feed (get-text-property (point) 'feed))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2862 (when feed |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2863 (save-excursion |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2864 (newsticker--buffer-beginning-of-item) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2865 (let ((inhibit-read-only t) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2866 (age (get-text-property (point) 'nt-age)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2867 (title (get-text-property (point) 'nt-title)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2868 (guid (get-text-property (point) 'nt-guid)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2869 (nt-desc (get-text-property (point) 'nt-desc)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2870 (pos (save-excursion (newsticker--buffer-end-of-item))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2871 item) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2872 (when (or (eq age 'new) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2873 (eq age 'obsolete) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2874 (and (eq age 'immortal) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2875 (not respect-immortality))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2876 ;; find item |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2877 (setq item (newsticker--cache-contains newsticker--cache |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2878 feed title nt-desc |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2879 nil nil guid)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2880 ;; mark as old |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2881 (when item |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2882 (setcar (nthcdr 4 item) 'old) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2883 (newsticker--do-forget-preformatted item)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2884 ;; clean up ticker |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2885 (if (or (and (eq age 'new) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2886 newsticker-hide-immortal-items-in-echo-area) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2887 (and (memq age '(old immortal)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2888 (not |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2889 (eq newsticker-hide-old-items-in-newsticker-buffer |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2890 newsticker-hide-immortal-items-in-echo-area)))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2891 (newsticker--ticker-text-remove feed title)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2892 ;; set faces etc. |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2893 (save-excursion |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2894 (save-restriction |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2895 (widen) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2896 (put-text-property (point) pos 'nt-age 'old) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2897 (newsticker--buffer-set-faces (point) pos))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2898 (set-buffer-modified-p nil))))))) |
65468 | 2899 |
2900 (defun newsticker-mark-item-at-point-as-immortal () | |
2901 "Mark item at point as read." | |
2902 (interactive) | |
2903 (when (or newsticker--buffer-uptodate-p | |
2904 (y-or-n-p | |
2905 "Buffer is not up to date -- really mark this item as read? ")) | |
2906 (let ((feed (get-text-property (point) 'feed)) | |
2907 (item nil)) | |
2908 (when feed | |
2909 (save-excursion | |
2910 (newsticker--buffer-beginning-of-item) | |
2911 (let ((inhibit-read-only t) | |
2912 (oldage (get-text-property (point) 'nt-age)) | |
2913 (title (get-text-property (point) 'nt-title)) | |
2914 (guid (get-text-property (point) 'nt-guid)) | |
2915 (pos (save-excursion (newsticker--buffer-end-of-item)))) | |
2916 (let ((newage 'immortal)) | |
2917 (if (eq oldage 'immortal) | |
2918 (setq newage 'old)) | |
2919 (setq item (newsticker--cache-contains newsticker--cache | |
2920 feed title nil nil nil | |
2921 guid)) | |
2922 ;; change age | |
2923 (when item | |
2924 (setcar (nthcdr 4 item) newage) | |
2925 (newsticker--do-forget-preformatted item)) | |
2926 (if (or (and (eq newage 'immortal) | |
2927 newsticker-hide-immortal-items-in-echo-area) | |
2928 (and (eq newage 'obsolete) | |
2929 newsticker-hide-obsolete-items-in-echo-area) | |
2930 (and (eq oldage 'immortal) | |
2931 (not | |
2932 (eq newsticker-hide-old-items-in-newsticker-buffer | |
2933 newsticker-hide-immortal-items-in-echo-area)))) | |
2934 (newsticker--ticker-text-remove feed title) | |
2935 (newsticker--ticker-text-setup)) | |
2936 (save-excursion | |
2937 (save-restriction | |
2938 (widen) | |
2939 (put-text-property (point) pos 'nt-age newage) | |
2940 (if (eq newage 'immortal) | |
2941 (put-text-property (point) pos 'nt-age 'immortal) | |
2942 (put-text-property (point) pos 'nt-age 'old)) | |
2943 (newsticker--buffer-set-faces (point) pos)))))) | |
2944 (if item | |
2945 (newsticker-next-item t)))))) | |
2946 | |
2947 (defun newsticker-mark-all-items-as-read () | |
2948 "Mark all items as read and clear ticker contents." | |
2949 (interactive) | |
2950 (when (or newsticker--buffer-uptodate-p | |
2951 (y-or-n-p | |
2952 "Buffer is not up to date -- really mark items as read? ")) | |
2953 (newsticker--cache-replace-age newsticker--cache 'any 'new 'old) | |
2954 (newsticker--buffer-set-uptodate nil) | |
2955 (newsticker--ticker-text-setup) | |
2956 (newsticker--cache-update) | |
2957 (newsticker-buffer-update))) | |
2958 | |
2959 (defun newsticker-hide-extra () | |
2960 "Hide the extra elements of items." | |
2961 (interactive) | |
2962 (newsticker--buffer-hideshow 'extra nil) | |
2963 (newsticker--buffer-redraw)) | |
2964 | |
2965 (defun newsticker-show-extra () | |
2966 "Show the extra elements of items." | |
2967 (interactive) | |
2968 (newsticker--buffer-hideshow 'extra t) | |
2969 (newsticker--buffer-redraw)) | |
2970 | |
2971 (defun newsticker-hide-old-item-desc () | |
2972 "Hide the description of old items." | |
2973 (interactive) | |
2974 (newsticker--buffer-hideshow 'desc-old nil) | |
2975 (newsticker--buffer-redraw)) | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
2976 |
65468 | 2977 (defun newsticker-show-old-item-desc () |
2978 "Show the description of old items." | |
2979 (interactive) | |
2980 (newsticker--buffer-hideshow 'item-old t) | |
2981 (newsticker--buffer-hideshow 'desc-old t) | |
2982 (newsticker--buffer-redraw)) | |
2983 | |
2984 (defun newsticker-hide-new-item-desc () | |
2985 "Hide the description of new items." | |
2986 (interactive) | |
2987 (newsticker--buffer-hideshow 'desc-new nil) | |
2988 (newsticker--buffer-hideshow 'desc-immortal nil) | |
2989 (newsticker--buffer-hideshow 'desc-obsolete nil) | |
2990 (newsticker--buffer-redraw)) | |
2991 | |
2992 (defun newsticker-show-new-item-desc () | |
2993 "Show the description of new items." | |
2994 (interactive) | |
2995 (newsticker--buffer-hideshow 'desc-new t) | |
2996 (newsticker--buffer-hideshow 'desc-immortal t) | |
2997 (newsticker--buffer-hideshow 'desc-obsolete t) | |
2998 (newsticker--buffer-redraw)) | |
2999 | |
3000 (defun newsticker-hide-feed-desc () | |
3001 "Hide the description of feeds." | |
3002 (interactive) | |
3003 (newsticker--buffer-hideshow 'desc-feed nil) | |
3004 (newsticker--buffer-redraw)) | |
3005 | |
3006 (defun newsticker-show-feed-desc () | |
3007 "Show the description of old items." | |
3008 (interactive) | |
3009 (newsticker--buffer-hideshow 'desc-feed t) | |
3010 (newsticker--buffer-redraw)) | |
3011 | |
3012 (defun newsticker-hide-all-desc () | |
3013 "Hide the descriptions of feeds and all items." | |
3014 (interactive) | |
3015 (newsticker--buffer-hideshow 'desc-feed nil) | |
3016 (newsticker--buffer-hideshow 'desc-immortal nil) | |
3017 (newsticker--buffer-hideshow 'desc-obsolete nil) | |
3018 (newsticker--buffer-hideshow 'desc-new nil) | |
3019 (newsticker--buffer-hideshow 'desc-old nil) | |
3020 (newsticker--buffer-redraw)) | |
3021 | |
3022 (defun newsticker-show-all-desc () | |
3023 "Show the descriptions of feeds and all items." | |
3024 (interactive) | |
3025 (newsticker--buffer-hideshow 'desc-feed t) | |
3026 (newsticker--buffer-hideshow 'desc-immortal t) | |
3027 (newsticker--buffer-hideshow 'desc-obsolete t) | |
3028 (newsticker--buffer-hideshow 'desc-new t) | |
3029 (newsticker--buffer-hideshow 'desc-old t) | |
3030 (newsticker--buffer-redraw)) | |
3031 | |
3032 (defun newsticker-hide-old-items () | |
3033 "Hide old items." | |
3034 (interactive) | |
3035 (newsticker--buffer-hideshow 'desc-old nil) | |
3036 (newsticker--buffer-hideshow 'item-old nil) | |
3037 (newsticker--buffer-redraw)) | |
3038 | |
3039 (defun newsticker-show-old-items () | |
3040 "Show old items." | |
3041 (interactive) | |
3042 (newsticker--buffer-hideshow 'item-old t) | |
3043 (newsticker--buffer-redraw)) | |
3044 | |
3045 (defun newsticker-hide-entry () | |
3046 "Hide description of entry at point." | |
3047 (interactive) | |
3048 (save-excursion | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
3049 (let* (pos1 pos2 |
65468 | 3050 (inhibit-read-only t) |
3051 inv-prop org-inv-prop | |
3052 is-invisible) | |
3053 (newsticker--buffer-beginning-of-item) | |
3054 (newsticker--buffer-goto '(desc)) | |
3055 (setq pos1 (max (point-min) (1- (point)))) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3056 (newsticker--buffer-goto '(extra feed item nil)) |
65468 | 3057 (setq pos2 (max (point-min) (1- (point)))) |
3058 (setq inv-prop (get-text-property pos1 'invisible)) | |
3059 (setq org-inv-prop (get-text-property pos1 'org-invisible)) | |
3060 (cond ((eq inv-prop t) | |
3061 ;; do nothing | |
3062 ) | |
3063 ((eq org-inv-prop nil) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3064 (add-text-properties pos1 pos2 |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3065 (list 'invisible (list t) |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3066 'org-invisible inv-prop))) |
65468 | 3067 (t |
3068 ;; toggle | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3069 (add-text-properties pos1 pos2 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3070 (list 'invisible org-inv-prop)) |
65468 | 3071 (remove-text-properties pos1 pos2 '(org-invisible)))))) |
3072 (newsticker--buffer-redraw)) | |
3073 | |
3074 (defun newsticker-show-entry () | |
3075 "Show description of entry at point." | |
3076 (interactive) | |
3077 (save-excursion | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
3078 (let* (pos1 pos2 |
65468 | 3079 (inhibit-read-only t) |
3080 inv-prop org-inv-prop | |
3081 is-invisible) | |
3082 (newsticker--buffer-beginning-of-item) | |
3083 (newsticker--buffer-goto '(desc)) | |
3084 (setq pos1 (max (point-min) (1- (point)))) | |
3085 (newsticker--buffer-goto '(extra feed item)) | |
3086 (setq pos2 (max (point-min) (1- (point)))) | |
3087 (setq inv-prop (get-text-property pos1 'invisible)) | |
3088 (setq org-inv-prop (get-text-property pos1 'org-invisible)) | |
3089 (cond ((eq org-inv-prop nil) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3090 (add-text-properties pos1 pos2 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3091 (list 'invisible nil |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3092 'org-invisible inv-prop))) |
65468 | 3093 (t |
3094 ;; toggle | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3095 (add-text-properties pos1 pos2 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3096 (list 'invisible org-inv-prop)) |
65468 | 3097 (remove-text-properties pos1 pos2 '(org-invisible)))))) |
3098 (newsticker--buffer-redraw)) | |
3099 | |
3100 (defun newsticker-toggle-auto-narrow-to-feed () | |
3101 "Toggle narrowing to current news feed. | |
3102 If auto-narrowing is active, only news item of the current feed | |
3103 are visible." | |
3104 (interactive) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3105 (newsticker-set-auto-narrow-to-feed |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3106 (not newsticker--auto-narrow-to-feed))) |
65468 | 3107 |
3108 (defun newsticker-set-auto-narrow-to-feed (value) | |
3109 "Turn narrowing to current news feed on or off. | |
3110 If VALUE is nil, auto-narrowing is turned off, otherwise it is turned on." | |
3111 (interactive) | |
3112 (setq newsticker--auto-narrow-to-item nil) | |
3113 (setq newsticker--auto-narrow-to-feed value) | |
3114 (widen) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3115 (newsticker--buffer-make-item-completely-visible) |
65468 | 3116 (run-hooks 'newsticker-narrow-hook)) |
3117 | |
3118 (defun newsticker-toggle-auto-narrow-to-item () | |
3119 "Toggle narrowing to current news item. | |
3120 If auto-narrowing is active, only one item of the current feed | |
3121 is visible." | |
3122 (interactive) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3123 (newsticker-set-auto-narrow-to-item |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3124 (not newsticker--auto-narrow-to-item))) |
65468 | 3125 |
3126 (defun newsticker-set-auto-narrow-to-item (value) | |
3127 "Turn narrowing to current news item on or off. | |
3128 If VALUE is nil, auto-narrowing is turned off, otherwise it is turned on." | |
3129 (interactive) | |
3130 (setq newsticker--auto-narrow-to-feed nil) | |
3131 (setq newsticker--auto-narrow-to-item value) | |
3132 (widen) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3133 (newsticker--buffer-make-item-completely-visible) |
65468 | 3134 (run-hooks 'newsticker-narrow-hook)) |
3135 | |
3136 (defun newsticker-customize () | |
3137 "Open the newsticker customization group." | |
3138 (interactive) | |
3139 (customize-group "newsticker")) | |
3140 | |
3141 (defun newsticker-next-feed-available-p () | |
3142 "Return t if position is before last feed, nil otherwise." | |
3143 (save-excursion | |
3144 (let ((p (point))) | |
3145 (newsticker--buffer-goto '(feed)) | |
3146 (not (= p (point)))))) | |
3147 | |
3148 (defun newsticker-previous-feed-available-p () | |
3149 "Return t if position is behind first feed, nil otherwise." | |
3150 (save-excursion | |
3151 (let ((p (point))) | |
3152 (newsticker--buffer-goto '(feed) nil t) | |
3153 (not (= p (point)))))) | |
3154 | |
3155 (defun newsticker-next-item-available-p () | |
3156 "Return t if position is before last feed, nil otherwise." | |
3157 (save-excursion | |
3158 (catch 'result | |
3159 (while (< (point) (point-max)) | |
3160 (unless (newsticker--buffer-goto '(item)) | |
3161 (throw 'result nil)) | |
3162 (unless (newsticker--lists-intersect-p | |
3163 (get-text-property (point) 'invisible) | |
3164 buffer-invisibility-spec) | |
3165 (throw 'result t)))))) | |
3166 | |
3167 (defun newsticker-previous-item-available-p () | |
3168 "Return t if position is behind first item, nil otherwise." | |
3169 (save-excursion | |
3170 (catch 'result | |
3171 (while (> (point) (point-min)) | |
3172 (unless (newsticker--buffer-goto '(item) nil t) | |
3173 (throw 'result nil)) | |
3174 (unless (newsticker--lists-intersect-p | |
3175 (get-text-property (point) 'invisible) | |
3176 buffer-invisibility-spec) | |
3177 (throw 'result t)))))) | |
3178 | |
3179 (defun newsticker-item-not-old-p () | |
3180 "Return t if there is an item at point which is not old, nil otherwise." | |
3181 (when (get-text-property (point) 'feed) | |
3182 (save-excursion | |
3183 (newsticker--buffer-beginning-of-item) | |
3184 (let ((age (get-text-property (point) 'nt-age))) | |
3185 (and (memq age '(new immortal obsolete)) t))))) | |
3186 | |
3187 (defun newsticker-item-not-immortal-p () | |
3188 "Return t if there is an item at point which is not immortal, nil otherwise." | |
3189 (when (get-text-property (point) 'feed) | |
3190 (save-excursion | |
3191 (newsticker--buffer-beginning-of-item) | |
3192 (let ((age (get-text-property (point) 'nt-age))) | |
3193 (and (memq age '(new old obsolete)) t))))) | |
3194 | |
3195 ;; ====================================================================== | |
3196 ;;; local stuff | |
3197 ;; ====================================================================== | |
3198 (defun newsticker-get-news (feed-name) | |
3199 "Get news from the site FEED-NAME and load feed logo. | |
3200 FEED-NAME must be a string which occurs as the label (i.e. the first element) | |
3201 in an element of `newsticker-url-list' or `newsticker-url-list-defaults'." | |
3202 (newsticker--debug-msg "%s: Getting news for %s" | |
3203 (format-time-string "%A, %H:%M" (current-time)) | |
3204 feed-name) | |
3205 (let* ((buffername (concat " *newsticker-wget-" feed-name "*")) | |
3206 (item (or (assoc feed-name newsticker-url-list) | |
3207 (assoc feed-name newsticker-url-list-defaults) | |
3208 (error | |
3209 "Cannot get news for %s: Check newsticker-url-list" | |
3210 feed-name))) | |
3211 (url (cadr item)) | |
3212 (wget-arguments (or (car (cdr (cdr (cdr (cdr item))))) | |
3213 newsticker-wget-arguments))) | |
3214 (save-excursion | |
3215 (set-buffer (get-buffer-create buffername)) | |
3216 (erase-buffer) | |
3217 ;; throw an error if there is an old wget-process around | |
3218 (if (get-process feed-name) | |
3219 (error "Another wget-process is running for %s" feed-name)) | |
3220 ;; start wget | |
3221 (let* ((args (append wget-arguments (list url))) | |
3222 (proc (apply 'start-process feed-name buffername | |
3223 newsticker-wget-name args))) | |
3224 (set-process-coding-system proc 'no-conversion 'no-conversion) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3225 (set-process-sentinel proc 'newsticker--sentinel) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3226 (setq newsticker--process-ids (cons (process-id proc) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3227 newsticker--process-ids)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3228 (force-mode-line-update))))) |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
3229 |
65468 | 3230 (defun newsticker-mouse-browse-url (event) |
3231 "Call `browse-url' for the link of the item at which the EVENT occurred." | |
3232 (interactive "e") | |
3233 (save-excursion | |
3234 (switch-to-buffer (window-buffer (posn-window (event-end event)))) | |
3235 (let ((url (get-text-property (posn-point (event-end event)) | |
3236 'nt-link))) | |
3237 (when url | |
3238 (browse-url url) | |
3239 (save-excursion | |
3240 (goto-char (posn-point (event-end event))) | |
3241 (if newsticker-automatically-mark-visited-items-as-old | |
3242 (newsticker-mark-item-at-point-as-read t))))))) | |
3243 | |
3244 (defun newsticker-browse-url () | |
3245 "Call `browse-url' for the link of the item at point." | |
3246 (interactive) | |
3247 (let ((url (get-text-property (point) 'nt-link))) | |
3248 (when url | |
3249 (browse-url url) | |
3250 (if newsticker-automatically-mark-visited-items-as-old | |
3251 (newsticker-mark-item-at-point-as-read t))))) | |
3252 | |
3253 (defvar newsticker-open-url-history | |
3254 '("wget" "xmms" "realplay") | |
3255 "...") | |
3256 | |
3257 (defun newsticker-handle-url () | |
3258 "Ask for a program to open the link of the item at point." | |
3259 (interactive) | |
3260 (let ((url (get-text-property (point) 'nt-link))) | |
3261 (when url | |
3262 (let ((prog (read-string "Open url with: " nil | |
3263 'newsticker-open-url-history))) | |
3264 (when prog | |
3265 (message "%s %s" prog url) | |
3266 (start-process prog prog prog url) | |
3267 (if newsticker-automatically-mark-visited-items-as-old | |
3268 (newsticker-mark-item-at-point-as-read t))))))) | |
3269 | |
3270 (defun newsticker--sentinel (process event) | |
3271 "Sentinel for extracting news titles from an RDF buffer. | |
3272 Argument PROCESS is the process which has just changed its state. | |
3273 Argument EVENT tells what has happened to the process." | |
3274 (let* ((p-status (process-status process)) | |
3275 (exit-status (process-exit-status process)) | |
3276 (time (current-time)) | |
3277 (name (process-name process)) | |
3278 (name-symbol (intern name)) | |
3279 (something-was-added nil)) | |
3280 ;; catch known errors (zombie processes, rubbish-xml etc. | |
3281 ;; if an error occurs the news feed is not updated! | |
3282 (catch 'oops | |
3283 (unless (and (eq p-status 'exit) | |
3284 (= exit-status 0)) | |
3285 (setq newsticker--cache | |
3286 (newsticker--cache-add | |
3287 newsticker--cache | |
3288 name-symbol | |
3289 newsticker--error-headline | |
3290 (format | |
3291 (concat "%s: Newsticker could not retrieve news from %s.\n" | |
3292 "Return status: `%s'\n" | |
3293 "Command was `%s'") | |
3294 (format-time-string "%A, %H:%M" (current-time)) | |
3295 name event (process-command process)) | |
3296 "" | |
3297 (current-time) | |
3298 'new | |
3299 0 nil)) | |
3300 (message "%s: Error while retrieving news from %s" | |
3301 (format-time-string "%A, %H:%M" (current-time)) | |
3302 (process-name process)) | |
3303 (throw 'oops nil)) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3304 (let* ((coding-system 'utf-8) |
65468 | 3305 (node-list |
3306 (save-current-buffer | |
3307 (set-buffer (process-buffer process)) | |
3308 ;; a very very dirty workaround to overcome the | |
3309 ;; problems with the newest (20030621) xml.el: | |
3310 ;; remove all unnecessary whitespace | |
3311 (goto-char (point-min)) | |
3312 (while (re-search-forward ">[ \t\r\n]+<" nil t) | |
3313 (replace-match "><" nil t)) | |
3314 ;; and another brutal workaround (20031105)! For some | |
3315 ;; reason the xml parser does not like the colon in the | |
3316 ;; doctype name "rdf:RDF" | |
3317 (goto-char (point-min)) | |
3318 (if (re-search-forward "<!DOCTYPE[ \t\n]+rdf:RDF" nil t) | |
3319 (replace-match "<!DOCTYPE rdfColonRDF" nil t)) | |
3320 ;; finally.... ~##^°!!!!! | |
3321 (goto-char (point-min)) | |
3322 (while (search-forward "\r\n" nil t) | |
3323 (replace-match "\n" nil t)) | |
3324 ;; still more brutal workarounds (20040309)! The xml | |
3325 ;; parser does not like doctype rss | |
3326 (goto-char (point-min)) | |
3327 (if (re-search-forward "<!DOCTYPE[ \t\n]+rss[ \t\n]*>" nil t) | |
3328 (replace-match "" nil t)) | |
3329 ;; And another one (20050618)! (Fixed in GNU Emacs 22.0.50.18) | |
3330 ;; Remove comments to avoid this xml-parsing bug: | |
3331 ;; "XML files can have only one toplevel tag" | |
3332 (goto-char (point-min)) | |
3333 (while (search-forward "<!--" nil t) | |
3334 (let ((start (match-beginning 0))) | |
3335 (unless (search-forward "-->" nil t) | |
3336 (error "Can't find end of comment")) | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
3337 (delete-region start (point)))) |
65468 | 3338 ;; And another one (20050702)! If description is HTML |
3339 ;; encoded and starts with a `<', wrap the whole | |
3340 ;; description in a CDATA expression. This happened for | |
3341 ;; http://www.thefreedictionary.com/_/WoD/rss.aspx?type=quote | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3342 (goto-char (point-min)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3343 (while (re-search-forward |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3344 "<description>\\(<img.*?\\)</description>" nil t) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3345 (replace-match |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3346 "<description><![CDATA[ \\1 ]]></description>")) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3347 ;; And another one (20051123)! XML parser does not like this: |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3348 ;; <yweather:location city="Frankfurt/Main" region="" country="GM" /> |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3349 ;; try to "fix" empty attributes |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3350 ;; This happened for |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3351 ;; http://xml.weather.yahoo.com/forecastrss?p=GMXX0040&u=f |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3352 (goto-char (point-min)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3353 (while (re-search-forward "\\(<[^>]*\\)=\"\"" nil t) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3354 (replace-match "\\1=\" \"")) |
65468 | 3355 ;; |
3356 (set-buffer-modified-p nil) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3357 ;; check coding system |
65468 | 3358 (goto-char (point-min)) |
3359 (if (re-search-forward "encoding=\"\\([^\"]+\\)\"" | |
3360 nil t) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3361 (setq coding-system (intern (downcase (match-string 1)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3362 (setq coding-system |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3363 (condition-case nil |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3364 (check-coding-system coding-system) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3365 (coding-system-error |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3366 (message |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3367 "newsticker.el: ignoring coding system %s for %s" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3368 coding-system name) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3369 nil)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3370 ;; Decode if possible |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3371 (when coding-system |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3372 (decode-coding-region (point-min) (point-max) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3373 coding-system)) |
65468 | 3374 (condition-case errordata |
3375 ;; The xml parser might fail | |
3376 ;; or the xml might be bugged | |
3377 (xml-parse-region (point-min) (point-max)) | |
3378 (error (message "Could not parse %s: %s" | |
3379 (buffer-name) (cadr errordata)) | |
3380 (throw 'oops nil))))) | |
3381 (topnode (car node-list)) | |
3382 (channelnode (car (xml-get-children topnode 'channel))) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3383 (imageurl nil)) |
65468 | 3384 ;; mark all items as obsolete |
3385 (newsticker--cache-replace-age newsticker--cache | |
3386 name-symbol | |
3387 'new 'obsolete-new) | |
3388 (newsticker--cache-replace-age newsticker--cache | |
3389 name-symbol | |
3390 'old 'obsolete-old) | |
3391 (newsticker--cache-replace-age newsticker--cache | |
3392 name-symbol | |
3393 'feed 'obsolete-old) | |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
3394 |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3395 ;; check Atom/RSS version and call corresponding parser |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3396 (condition-case error-data |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3397 (if (cond |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3398 ;; RSS 0.91 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3399 ((and (eq 'rss (xml-node-name topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3400 (string= "0.91" (xml-get-attribute topnode 'version))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3401 (setq imageurl (newsticker--get-logo-url-rss-0.91 topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3402 (newsticker--parse-rss-0.91 name time topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3403 ;; RSS 0.92 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3404 ((and (eq 'rss (xml-node-name topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3405 (string= "0.92" (xml-get-attribute topnode 'version))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3406 (setq imageurl (newsticker--get-logo-url-rss-0.92 topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3407 (newsticker--parse-rss-0.92 name time topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3408 ;; RSS 1.0 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3409 ((eq 'rdf:RDF (xml-node-name topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3410 (setq imageurl (newsticker--get-logo-url-rss-1.0 topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3411 (newsticker--parse-rss-1.0 name time topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3412 ;; RSS 2.0 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3413 ((and (eq 'rss (xml-node-name topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3414 (string= "2.0" (xml-get-attribute topnode 'version))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3415 (setq imageurl (newsticker--get-logo-url-rss-2.0 topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3416 (newsticker--parse-rss-2.0 name time topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3417 ;; Atom 0.3 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3418 ((and (eq 'feed (xml-node-name topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3419 (string= "http://purl.org/atom/ns#" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3420 (xml-get-attribute topnode 'xmlns))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3421 (setq imageurl (newsticker--get-logo-url-atom-0.3 topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3422 (newsticker--parse-atom-0.3 name time topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3423 ;; Atom 1.0 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3424 ((and (eq 'feed (xml-node-name topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3425 (string= "http://www.w3.org/2005/Atom" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3426 (xml-get-attribute topnode 'xmlns))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3427 (setq imageurl (newsticker--get-logo-url-atom-1.0 topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3428 (newsticker--parse-atom-1.0 name time topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3429 ;; unknown feed type |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3430 (t |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3431 (newsticker--debug-msg "Feed type unknown: %s: %s" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3432 (xml-node-name topnode) name) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3433 nil)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3434 (setq something-was-added t)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3435 (xerror (message "sentinelerror in %s: %s" name error-data))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3436 |
65468 | 3437 ;; Remove those old items from cache which have been removed from |
3438 ;; the feed | |
3439 (newsticker--cache-replace-age newsticker--cache | |
3440 name-symbol 'obsolete-old 'deleteme) | |
3441 (newsticker--cache-remove newsticker--cache name-symbol | |
3442 'deleteme) | |
3443 ;; Remove those new items from cache which have been removed from | |
3444 ;; the feed. Or keep them as `obsolete' | |
3445 (if (not newsticker-keep-obsolete-items) | |
3446 (newsticker--cache-remove newsticker--cache | |
3447 name-symbol 'obsolete-new) | |
3448 (setq newsticker--cache | |
3449 (newsticker--cache-mark-expired | |
3450 newsticker--cache name-symbol 'obsolete 'obsolete-expired | |
3451 newsticker-obsolete-item-max-age)) | |
3452 (newsticker--cache-remove newsticker--cache | |
3453 name-symbol 'obsolete-expired) | |
3454 (newsticker--cache-replace-age newsticker--cache | |
3455 name-symbol 'obsolete-new | |
3456 'obsolete)) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3457 (newsticker--update-process-ids) |
65468 | 3458 ;; setup scrollable text |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3459 (when (= 0 (length newsticker--process-ids)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3460 (newsticker--ticker-text-setup)) |
65468 | 3461 (setq newsticker--latest-update-time (current-time)) |
3462 (when something-was-added | |
3463 ;; FIXME: should we care about removed items as well? | |
3464 (newsticker--cache-update) | |
3465 (newsticker--buffer-set-uptodate nil)) | |
3466 ;; kill the process buffer if wanted | |
3467 (unless newsticker-debug | |
3468 (kill-buffer (process-buffer process))) | |
3469 ;; launch retrieval of image | |
3470 (when (and imageurl | |
3471 (string-match "%l" newsticker-heading-format)) | |
3472 (newsticker--image-get name imageurl)))))) | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
3473 |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3474 (defun newsticker--get-logo-url-atom-1.0 (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3475 "Return logo URL from atom 1.0 data in NODE." |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3476 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3477 (car (xml-get-children node 'logo))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3478 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3479 (defun newsticker--get-logo-url-atom-0.3 (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3480 "Return logo URL from atom 0.3 data in NODE." |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3481 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3482 (car (xml-get-children (car (xml-get-children node 'image)) 'url))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3483 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3484 (defun newsticker--get-logo-url-rss-2.0 (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3485 "Return logo URL from RSS 2.0 data in NODE." |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3486 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3487 (car (xml-get-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3488 (car (xml-get-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3489 (car (xml-get-children node 'channel)) 'image)) 'url))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3490 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3491 (defun newsticker--get-logo-url-rss-1.0 (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3492 "Return logo URL from RSS 1.0 data in NODE." |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3493 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3494 (car (xml-get-children (car (xml-get-children node 'image)) 'url))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3495 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3496 (defun newsticker--get-logo-url-rss-0.92 (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3497 "Return logo URL from RSS 0.92 data in NODE." |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3498 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3499 (car (xml-get-children (car (xml-get-children node 'image)) 'url))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3500 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3501 (defun newsticker--get-logo-url-rss-0.91 (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3502 "Return logo URL from RSS 0.91 data in NODE." |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3503 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3504 (car (xml-get-children (car (xml-get-children node 'image)) 'url))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3505 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3506 (defun newsticker--parse-atom-0.3 (name time topnode) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3507 "Parse Atom 0.3 data. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3508 Return value as well as arguments NAME, TIME, and TOPNODE are the |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
3509 same as in `newsticker--parse-atom-1.0'." |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3510 (newsticker--debug-msg "Parsing Atom 0.3 feed %s" name) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3511 (let (new-feed new-item) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3512 (setq new-feed (newsticker--parse-generic-feed |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3513 name time |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3514 ;; title |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3515 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3516 (car (xml-get-children topnode 'title)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3517 ;; desc |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3518 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3519 (car (xml-get-children topnode 'content)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3520 ;; link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3521 (xml-get-attribute |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3522 (car (xml-get-children topnode 'link)) 'href) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3523 ;; extra-elements |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3524 (xml-node-children topnode))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3525 (setq new-item (newsticker--parse-generic-items |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3526 name time (xml-get-children topnode 'entry) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3527 ;; title-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3528 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3529 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3530 (car (xml-get-children node 'title))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3531 ;; desc-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3532 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3533 (or (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3534 (car (xml-get-children node 'content)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3535 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3536 (car (xml-get-children node 'summary)))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3537 ;; link-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3538 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3539 (xml-get-attribute |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3540 (car (xml-get-children node 'link)) 'href)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3541 ;; time-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3542 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3543 (newsticker--decode-rfc822-date |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3544 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3545 (car (xml-get-children node 'modified)))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3546 ;; guid-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3547 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3548 (let ((tguid (assoc 'guid (xml-node-children node)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3549 (if (stringp tguid) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3550 tguid |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3551 (car (xml-node-children tguid))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3552 ;; extra-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3553 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3554 (xml-node-children node)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3555 (or new-item new-feed))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3556 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3557 (defun newsticker--parse-atom-1.0 (name time topnode) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3558 "Parse Atom 1.0 data. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3559 Argument NAME gives the name of a news feed. TIME gives the |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3560 system time at which the data have been retrieved. TOPNODE |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3561 contains the feed data as returned by the xml parser. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3562 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3563 For the Atom 1.0 specification see |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3564 http://www.atompub.org/2005/08/17/draft-ietf-atompub-format-11.html" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3565 (newsticker--debug-msg "Parsing Atom 1.0 feed %s" name) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3566 (let (new-feed new-item) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3567 (setq new-feed (newsticker--parse-generic-feed |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3568 name time |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3569 ;; title |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3570 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3571 (car (xml-get-children topnode 'title)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3572 ;; desc |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3573 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3574 (car (xml-get-children topnode 'subtitle)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3575 ;; link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3576 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3577 (car (xml-get-children topnode 'link)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3578 ;; extra-elements |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3579 (xml-node-children topnode))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3580 (setq new-item (newsticker--parse-generic-items |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3581 name time (xml-get-children topnode 'entry) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3582 ;; title-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3583 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3584 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3585 (car (xml-get-children node 'title))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3586 ;; desc-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3587 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3588 (or (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3589 (car (xml-get-children node 'content)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3590 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3591 (car (xml-get-children node 'summary)))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3592 ;; link-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3593 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3594 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3595 (car (xml-get-children node 'link))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3596 ;; time-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3597 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3598 (newsticker--decode-iso8601-date |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3599 (or (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3600 (car (xml-get-children node 'updated)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3601 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3602 (car (xml-get-children node 'published))))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3603 ;; guid-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3604 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3605 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3606 (car (xml-get-children node 'id))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3607 ;; extra-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3608 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3609 (xml-node-children node)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3610 (or new-item new-feed))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3611 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3612 (defun newsticker--parse-rss-0.91 (name time topnode) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3613 "Parse RSS 0.91 data. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3614 Return value as well as arguments NAME, TIME, and TOPNODE are the |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3615 same as in `newsticker--parse-atom-1.0'. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3616 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3617 For the RSS 0.91 specification see http://backend.userland.com/rss091 or |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3618 http://my.netscape.com/publish/formats/rss-spec-0.91.html." |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3619 (newsticker--debug-msg "Parsing RSS 0.91 feed %s" name) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3620 (let* ((channelnode (car (xml-get-children topnode 'channel))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3621 (pub-date (newsticker--decode-rfc822-date |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3622 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3623 (car (xml-get-children channelnode 'pubDate)))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3624 is-new-feed has-new-items) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3625 (setq is-new-feed (newsticker--parse-generic-feed |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3626 name time |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3627 ;; title |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3628 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3629 (car (xml-get-children channelnode 'title)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3630 ;; desc |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3631 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3632 (car (xml-get-children channelnode |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3633 'description)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3634 ;; link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3635 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3636 (car (xml-get-children channelnode 'link)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3637 ;; extra-elements |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3638 (xml-node-children channelnode))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3639 (setq has-new-items (newsticker--parse-generic-items |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3640 name time (xml-get-children channelnode 'item) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3641 ;; title-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3642 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3643 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3644 (car (xml-get-children node 'title))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3645 ;; desc-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3646 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3647 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3648 (car (xml-get-children node 'description))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3649 ;; link-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3650 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3651 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3652 (car (xml-get-children node 'link))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3653 ;; time-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3654 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3655 pub-date) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3656 ;; guid-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3657 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3658 nil) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3659 ;; extra-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3660 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3661 (xml-node-children node)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3662 (or has-new-items is-new-feed))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3663 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3664 (defun newsticker--parse-rss-0.92 (name time topnode) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3665 "Parse RSS 0.92 data. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3666 Return value as well as arguments NAME, TIME, and TOPNODE are the |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3667 same as in `newsticker--parse-atom-1.0'. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3668 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3669 For the RSS 0.92 specification see http://backend.userland.com/rss092." |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3670 (newsticker--debug-msg "Parsing RSS 0.92 feed %s" name) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3671 (let* ((channelnode (car (xml-get-children topnode 'channel))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3672 (pub-date (newsticker--decode-rfc822-date |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3673 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3674 (car (xml-get-children channelnode 'pubDate)))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3675 is-new-feed has-new-items) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3676 (setq is-new-feed (newsticker--parse-generic-feed |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3677 name time |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3678 ;; title |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3679 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3680 (car (xml-get-children channelnode 'title)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3681 ;; desc |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3682 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3683 (car (xml-get-children channelnode |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3684 'description)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3685 ;; link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3686 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3687 (car (xml-get-children channelnode 'link)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3688 ;; extra-elements |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3689 (xml-node-children channelnode))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3690 (setq has-new-items (newsticker--parse-generic-items |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3691 name time (xml-get-children channelnode 'item) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3692 ;; title-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3693 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3694 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3695 (car (xml-get-children node 'title))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3696 ;; desc-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3697 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3698 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3699 (car (xml-get-children node 'description))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3700 ;; link-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3701 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3702 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3703 (car (xml-get-children node 'link))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3704 ;; time-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3705 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3706 pub-date) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3707 ;; guid-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3708 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3709 nil) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3710 ;; extra-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3711 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3712 (xml-node-children node)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3713 (or has-new-items is-new-feed))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3714 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3715 (defun newsticker--parse-rss-1.0 (name time topnode) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3716 "Parse RSS 1.0 data. |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
3717 Return value as well as arguments NAME, TIME, and TOPNODE are the |
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
3718 same as in `newsticker--parse-atom-1.0'. |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3719 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3720 For the RSS 1.0 specification see http://web.resource.org/rss/1.0/spec." |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3721 (newsticker--debug-msg "Parsing RSS 1.0 feed %s" name) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3722 (let* ((channelnode (car (xml-get-children topnode 'channel))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3723 is-new-feed has-new-items) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3724 (setq is-new-feed (newsticker--parse-generic-feed |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3725 name time |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3726 ;; title |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3727 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3728 (car (xml-get-children channelnode 'title)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3729 ;; desc |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3730 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3731 (car (xml-get-children channelnode |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3732 'description)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3733 ;; link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3734 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3735 (car (xml-get-children channelnode 'link)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3736 ;; extra-elements |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3737 (xml-node-children channelnode))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3738 (setq has-new-items (newsticker--parse-generic-items |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3739 name time (xml-get-children topnode 'item) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3740 ;; title-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3741 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3742 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3743 (car (xml-get-children node 'title))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3744 ;; desc-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3745 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3746 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3747 (car (xml-get-children node |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3748 'description))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3749 ;; link-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3750 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3751 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3752 (car (xml-get-children node 'link))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3753 ;; time-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3754 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3755 (newsticker--decode-iso8601-date |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3756 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3757 (car (xml-get-children node 'dc:date)))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3758 ;; guid-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3759 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3760 nil) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3761 ;; extra-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3762 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3763 (xml-node-children node)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3764 (or has-new-items is-new-feed))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3765 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3766 (defun newsticker--parse-rss-2.0 (name time topnode) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3767 "Parse RSS 2.0 data. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3768 Return value as well as arguments NAME, TIME, and TOPNODE are the |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3769 same as in `newsticker--parse-atom-1.0'. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3770 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3771 For the RSS 2.0 specification see http://blogs.law.harvard.edu/tech/rss." |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3772 (newsticker--debug-msg "Parsing RSS 2.0 feed %s" name) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3773 (let* ((channelnode (car (xml-get-children topnode 'channel))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3774 is-new-feed has-new-items) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3775 (setq is-new-feed (newsticker--parse-generic-feed |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3776 name time |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3777 ;; title |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3778 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3779 (car (xml-get-children channelnode 'title)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3780 ;; desc |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3781 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3782 (car (xml-get-children channelnode |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3783 'description)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3784 ;; link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3785 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3786 (car (xml-get-children channelnode 'link)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3787 ;; extra-elements |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3788 (xml-node-children channelnode))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3789 (setq has-new-items (newsticker--parse-generic-items |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3790 name time (xml-get-children channelnode 'item) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3791 ;; title-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3792 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3793 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3794 (car (xml-get-children node 'title))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3795 ;; desc-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3796 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3797 (or (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3798 (car (xml-get-children node |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3799 'content:encoded)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3800 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3801 (car (xml-get-children node |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3802 'description)))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3803 ;; link-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3804 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3805 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3806 (car (xml-get-children node 'link))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3807 ;; time-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3808 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3809 (newsticker--decode-rfc822-date |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3810 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3811 (car (xml-get-children node 'pubDate)))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3812 ;; guid-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3813 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3814 (let* ((tguid (assoc 'guid |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3815 (xml-node-children node)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3816 (if (stringp tguid) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3817 tguid |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3818 (car (xml-node-children tguid))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3819 ;; extra-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3820 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3821 (xml-node-children node)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3822 (or has-new-items is-new-feed))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3823 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3824 (defun newsticker--parse-generic-feed (name time title desc link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3825 extra-elements) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3826 "Parse generic news feed data. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3827 Argument NAME gives the name of a news feed. TIME gives the |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
3828 system time at which the data have been retrieved. |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3829 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3830 The arguments TITLE, DESC, LINK, and EXTRA-ELEMENTS give the feed's title, |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3831 description, link, and extra elements resp." |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3832 (let ((title (or title "[untitled]")) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3833 (link (or link "")) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3834 (old-item nil) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3835 (position 0) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3836 (something-was-added nil)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3837 ;; decode numeric entities |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3838 (setq title (newsticker--decode-numeric-entities title)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3839 (setq desc (newsticker--decode-numeric-entities desc)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3840 (setq link (newsticker--decode-numeric-entities link)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3841 ;; remove whitespace from title, desc, and link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3842 (setq title (newsticker--remove-whitespace title)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3843 (setq desc (newsticker--remove-whitespace desc)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3844 (setq link (newsticker--remove-whitespace link)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3845 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3846 ;; handle the feed itself |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3847 (unless (newsticker--cache-contains newsticker--cache |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3848 (intern name) title |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3849 desc link 'feed) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3850 (setq something-was-added t)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3851 (setq newsticker--cache |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3852 (newsticker--cache-add newsticker--cache (intern name) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3853 title desc link time 'feed position |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3854 extra-elements 'feed time)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3855 something-was-added)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3856 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3857 (defun newsticker--parse-generic-items (name time itemlist |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3858 title-fn desc-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3859 link-fn time-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3860 guid-fn extra-fn) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3861 "Parse generic news feed data. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3862 Argument NAME gives the name of a news feed. TIME gives the |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3863 system time at which the data have been retrieved. ITEMLIST |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3864 contains the news items returned by the xml parser. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3865 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3866 The arguments TITLE-FN, DESC-FN, LINK-FN, TIME-FN, GUID-FN, and |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3867 EXTRA-FN give functions for extracting title, description, link, |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3868 time, guid, and extra-elements resp. They are called with one |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3869 argument, which is one of the items in ITEMLIST." |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3870 (let (title desc link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3871 (old-item nil) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3872 (position 0) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3873 (something-was-added nil)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3874 ;; gather all items for this feed |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3875 (mapc (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3876 (setq position (1+ position)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3877 (setq title (or (funcall title-fn node) "[untitled]")) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3878 (setq desc (funcall desc-fn node)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3879 (setq link (or (funcall link-fn node) "")) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3880 (setq time (or (funcall time-fn node) time)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3881 ;; It happened that the title or description |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3882 ;; contained evil HTML code that confused the |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3883 ;; xml parser. Therefore: |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3884 (unless (stringp title) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3885 (setq title (prin1-to-string title))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3886 (unless (or (stringp desc) (not desc)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3887 (setq desc (prin1-to-string desc))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3888 ;; ignore items with empty title AND empty desc |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3889 (when (or (> (length title) 0) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3890 (> (length desc) 0)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3891 ;; decode numeric entities |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3892 (setq title (newsticker--decode-numeric-entities title)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3893 (when desc |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3894 (setq desc (newsticker--decode-numeric-entities desc))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3895 (setq link (newsticker--decode-numeric-entities link)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3896 ;; remove whitespace from title, desc, and link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3897 (setq title (newsticker--remove-whitespace title)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3898 (setq desc (newsticker--remove-whitespace desc)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3899 (setq link (newsticker--remove-whitespace link)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3900 ;; add data to cache |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3901 ;; do we have this item already? |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3902 (let* ((guid (funcall guid-fn node))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3903 ;;(message "guid=%s" guid) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3904 (setq old-item |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3905 (newsticker--cache-contains newsticker--cache |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3906 (intern name) title |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3907 desc link nil guid))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3908 ;; add this item, or mark it as old, or do nothing |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3909 (let ((age1 'new) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3910 (age2 'old) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3911 (item-new-p nil)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3912 (if old-item |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3913 (let ((prev-age (newsticker--age old-item))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3914 (unless |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3915 newsticker-automatically-mark-items-as-old |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3916 (if (eq prev-age 'obsolete-old) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3917 (setq age2 'old) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3918 (setq age2 'new))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3919 (if (eq prev-age 'immortal) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3920 (setq age2 'immortal))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3921 ;; item was not there |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3922 (setq item-new-p t) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3923 (setq something-was-added t)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3924 (setq newsticker--cache |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3925 (newsticker--cache-add |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3926 newsticker--cache (intern name) title desc link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3927 time age1 position (funcall extra-fn node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3928 age2)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3929 (when item-new-p |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3930 (let ((item (newsticker--cache-contains |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3931 newsticker--cache (intern name) title |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3932 desc link nil))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3933 (if newsticker-auto-mark-filter-list |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3934 (newsticker--run-auto-mark-filter name item)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3935 (run-hook-with-args |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3936 'newsticker-new-item-functions name item)))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3937 itemlist) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3938 something-was-added)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3939 |
65468 | 3940 (defun newsticker--display-tick () |
3941 "Called from the display timer. | |
3942 This function calls a display function, according to the variable | |
3943 `newsticker-scroll-smoothly'." | |
3944 (if newsticker-scroll-smoothly | |
3945 (newsticker--display-scroll) | |
3946 (newsticker--display-jump))) | |
3947 | |
3948 (defsubst newsticker--echo-area-clean-p () | |
3949 "Check whether somebody is using the echo area / minibuffer. | |
3950 Return t if echo area and minibuffer are unused." | |
3951 (not (or (active-minibuffer-window) | |
3952 (and (current-message) | |
3953 (not (string= (current-message) | |
3954 newsticker--prev-message)))))) | |
3955 | |
3956 (defun newsticker--display-jump () | |
3957 "Called from the display timer. | |
3958 This function displays the next ticker item in the echo area, unless | |
3959 there is another message displayed or the minibuffer is active." | |
3960 (let ((message-log-max nil));; prevents message text from being logged | |
3961 (when (newsticker--echo-area-clean-p) | |
3962 (setq newsticker--item-position (1+ newsticker--item-position)) | |
3963 (when (>= newsticker--item-position (length newsticker--item-list)) | |
3964 (setq newsticker--item-position 0)) | |
3965 (setq newsticker--prev-message | |
3966 (nth newsticker--item-position newsticker--item-list)) | |
65586
86bece058ee5
Message format fixes (commit no. 5)
Deepak Goel <deego@gnufans.org>
parents:
65490
diff
changeset
|
3967 (message "%s" newsticker--prev-message)))) |
65468 | 3968 |
3969 (defun newsticker--display-scroll () | |
3970 "Called from the display timer. | |
3971 This function scrolls the ticker items in the echo area, unless | |
3972 there is another message displayed or the minibuffer is active." | |
3973 (when (newsticker--echo-area-clean-p) | |
3974 (let* ((width (- (frame-width) 1)) | |
3975 (message-log-max nil);; prevents message text from being logged | |
3976 (i newsticker--item-position) | |
3977 subtext | |
3978 (s-text newsticker--scrollable-text) | |
3979 (l (length s-text))) | |
3980 ;; don't show anything if there is nothing to show | |
3981 (unless (< (length s-text) 1) | |
3982 ;; repeat the ticker string if it is shorter than frame width | |
3983 (while (< (length s-text) width) | |
3984 (setq s-text (concat s-text s-text))) | |
3985 ;; get the width of the printed string | |
3986 (setq l (length s-text)) | |
3987 (cond ((< i (- l width)) | |
3988 (setq subtext (substring s-text i (+ i width)))) | |
3989 (t | |
3990 (setq subtext (concat | |
3991 (substring s-text i l) | |
3992 (substring s-text 0 (- width (- l i))))))) | |
3993 ;; Take care of multibyte strings, for which (string-width) is | |
3994 ;; larger than (length). | |
3995 ;; Actually, such strings may be smaller than (frame-width) | |
3996 ;; because return values of (string-width) are too large: | |
3997 ;; (string-width "<japanese character>") => 2 | |
3998 (let ((t-width (1- (length subtext)))) | |
3999 (while (> (string-width subtext) width) | |
4000 (setq subtext (substring subtext 0 t-width)) | |
4001 (setq t-width (1- t-width)))) | |
4002 ;; show the ticker text and save current position | |
65586
86bece058ee5
Message format fixes (commit no. 5)
Deepak Goel <deego@gnufans.org>
parents:
65490
diff
changeset
|
4003 (message "%s" subtext) |
65468 | 4004 (setq newsticker--prev-message subtext) |
4005 (setq newsticker--item-position (1+ i)) | |
4006 (when (>= newsticker--item-position l) | |
4007 (setq newsticker--item-position 0)))))) | |
4008 | |
4009 ;; ====================================================================== | |
4010 ;;; misc | |
4011 ;; ====================================================================== | |
4012 (defun newsticker--decode-numeric-entities (string) | |
4013 "Decode SGML numeric entities by their respective utf characters. | |
4014 This function replaces numeric entities in the input STRING and | |
4015 returns the modified string. For example \"*\" gets replaced | |
4016 by \"*\"." | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4017 (if (and string (stringp string)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4018 (let ((start 0)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4019 (while (string-match "&#\\([0-9]+\\);" string start) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4020 (condition-case nil |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4021 (setq string (replace-match |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4022 (string (read (substring string |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4023 (match-beginning 1) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4024 (match-end 1)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4025 nil nil string)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4026 (error nil)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4027 (setq start (1+ (match-beginning 0)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4028 string) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4029 nil)) |
65468 | 4030 |
4031 (defun newsticker--remove-whitespace (string) | |
4032 "Remove leading and trailing whitespace from STRING." | |
4033 ;; we must have ...+ but not ...* in the regexps otherwise xemacs loops | |
4034 ;; endlessly... | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4035 (when (and string (stringp string)) |
65468 | 4036 (replace-regexp-in-string |
4037 "[ \t\r\n]+$" "" | |
4038 (replace-regexp-in-string "^[ \t\r\n]+" "" string)))) | |
4039 | |
4040 (defun newsticker--do-forget-preformatted (item) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4041 "Forget pre-formatted data for ITEM. |
65468 | 4042 Remove the pre-formatted from `newsticker--cache'." |
4043 (if (nthcdr 7 item) | |
4044 (setcar (nthcdr 7 item) nil)) | |
4045 (if (nthcdr 6 item) | |
4046 (setcar (nthcdr 6 item) nil))) | |
4047 | |
4048 (defun newsticker--forget-preformatted () | |
4049 "Forget all cached pre-formatted data. | |
4050 Remove the pre-formatted from `newsticker--cache'." | |
4051 (mapc (lambda (feed) | |
4052 (mapc 'newsticker--do-forget-preformatted | |
4053 (cdr feed))) | |
4054 newsticker--cache) | |
4055 (newsticker--buffer-set-uptodate nil)) | |
4056 | |
4057 (defun newsticker--debug-msg (string &rest args) | |
4058 "Print newsticker debug messages. | |
4059 This function calls `message' with arguments STRING and ARGS, if | |
4060 `newsticker-debug' is non-nil." | |
4061 (and newsticker-debug | |
4062 ;;(not (active-minibuffer-window)) | |
4063 ;;(not (current-message)) | |
4064 (apply 'message string args))) | |
4065 | |
4066 (defun newsticker--decode-iso8601-date (iso8601-string) | |
4067 "Return ISO8601-STRING in format like `decode-time'. | |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
4068 Converts from ISO-8601 to Emacs representation. |
65468 | 4069 Examples: |
4070 2004-09-17T05:09:49+00:00 | |
4071 2004-09-17T05:09+00:00 | |
4072 2004-09-17T05:09:49 | |
4073 2004-09-17T05:09 | |
4074 2004-09-17 | |
4075 2004-09 | |
4076 2004" | |
4077 (if iso8601-string | |
4078 (when (string-match | |
4079 (concat | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
4080 "^ *\\([0-9]\\{4\\}\\)" |
65468 | 4081 "\\(-\\([0-9]\\{2\\}\\)" |
4082 "\\(-\\([0-9]\\{2\\}\\)" | |
4083 "\\(T" | |
4084 "\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)" | |
4085 "\\(:\\([0-9]\\{2\\}\\)\\)?" | |
4086 "\\(\\([-+Z]\\)\\(\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)?" | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
4087 "\\)?\\)?\\)? *$") |
65468 | 4088 iso8601-string) |
4089 (let ((year (read (match-string 1 iso8601-string))) | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
4090 (month (read (or (match-string 3 iso8601-string) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
4091 "1"))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
4092 (day (read (or (match-string 5 iso8601-string) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
4093 "1"))) |
65468 | 4094 (hour (read (or (match-string 7 iso8601-string) |
4095 "0"))) | |
4096 (minute (read (or (match-string 8 iso8601-string) | |
4097 "0"))) | |
4098 ;;(second (read (or (match-string 10 iso8601-string) | |
4099 ;; "0"))) | |
4100 (sign (match-string 12 iso8601-string)) | |
4101 (offset-hour (read (or (match-string 14 iso8601-string) | |
4102 "0"))) | |
4103 (offset-minute (read (or (match-string 15 iso8601-string) | |
4104 "0"))) | |
4105 (second 0)) | |
4106 (cond ((string= sign "+") | |
4107 (setq hour (- hour offset-hour)) | |
4108 (setq minute (- minute offset-minute))) | |
4109 ((string= sign "-") | |
4110 (setq hour (+ hour offset-hour)) | |
4111 (setq minute (+ minute offset-minute)))) | |
4112 ;; if UTC subtract current-time-zone offset | |
4113 ;;(setq second (+ (car (current-time-zone)) second))) | |
4114 | |
4115 (condition-case nil | |
4116 (encode-time second minute hour day month year t) | |
4117 (error | |
4118 (message "Cannot decode \"%s\"" iso8601-string) | |
4119 nil)))) | |
4120 nil)) | |
4121 | |
4122 (defun newsticker--decode-rfc822-date (rfc822-string) | |
4123 "Return RFC822-STRING in format like `decode-time'. | |
4124 Converts from RFC822 to Emacs representation. | |
4125 Examples: | |
4126 Sat, 07 Sep 2002 00:00:01 GMT | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4127 07 Sep 2002 00:00:01 GMT |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4128 07 Sep 2002" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4129 (if (and rfc822-string (stringp rfc822-string)) |
65468 | 4130 (when (string-match |
4131 (concat | |
4132 "\\s-*" | |
4133 ;; week day | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4134 "\\(\\(Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\|Sun\\)\\s-*,?\\)?\\s-*" |
65468 | 4135 ;; day |
4136 "\\([0-9]\\{1,2\\}\\)\\s-+" | |
4137 ;; month | |
4138 "\\(Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|Jul\\|Aug\\|" | |
4139 "Sep\\|Oct\\|Nov\\|Dec\\)\\s-+" | |
4140 ;; year | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4141 "\\([0-9]\\{2,4\\}\\)" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4142 ;; time may be missing |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4143 "\\(\\s-+" |
65468 | 4144 ;; hour |
4145 "\\([0-9]\\{2\\}\\)" | |
4146 ;; minute | |
4147 ":\\([0-9]\\{2\\}\\)" | |
4148 ;; second | |
4149 "\\(:\\([0-9]\\{2\\}\\)\\)?" | |
4150 ;; zone -- fixme | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4151 "\\(\\s-+.*\\)?" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4152 "\\)?") |
65468 | 4153 rfc822-string) |
4154 (let ((day (read (match-string 3 rfc822-string))) | |
4155 (month-name (match-string 4 rfc822-string)) | |
4156 (month 0) | |
4157 (year (read (match-string 5 rfc822-string))) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4158 (hour (read (or (match-string 7 rfc822-string) "0"))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4159 (minute (read (or (match-string 8 rfc822-string) "0"))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4160 (second (read (or (match-string 10 rfc822-string) "0"))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4161 ;;(zone (match-string 11 rfc822-string)) |
65468 | 4162 ) |
4163 (condition-case error-data | |
4164 (let ((i 1)) | |
4165 (mapc (lambda (m) | |
4166 (if (string= month-name m) | |
4167 (setq month i)) | |
4168 (setq i (1+ i))) | |
4169 '("Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" | |
4170 "Sep" "Oct" "Nov" "Dec")) | |
4171 (encode-time second minute hour day month year t)) | |
4172 (error | |
4173 (message "Cannot decode \"%s\": %s %s" rfc822-string | |
4174 (car error-data) (cdr error-data)) | |
4175 nil)))) | |
4176 nil)) | |
4177 | |
4178 (defun newsticker--lists-intersect-p (list1 list2) | |
4179 "Return t if LIST1 and LIST2 share elements." | |
4180 (let ((result nil)) | |
4181 (mapc (lambda (elt) | |
4182 (if (memq elt list2) | |
4183 (setq result t))) | |
4184 list1) | |
4185 result)) | |
4186 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4187 (defun newsticker--update-process-ids () |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4188 "Update list of ids of active newsticker processes. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4189 Checks list of active processes against list of newsticker processes." |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4190 (let ((active-procs (process-list)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4191 (new-list nil)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4192 (mapc (lambda (proc) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4193 (let ((id (process-id proc))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4194 (if (memq id newsticker--process-ids) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4195 (setq new-list (cons id new-list))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4196 active-procs) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4197 (setq newsticker--process-ids new-list)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4198 (force-mode-line-update)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4199 |
65468 | 4200 ;; ====================================================================== |
4201 ;;; images | |
4202 ;; ====================================================================== | |
4203 (defun newsticker--image-get (feed-name url) | |
4204 "Get image of the news site FEED-NAME from URL. | |
4205 If the image has been downloaded in the last 24h do nothing." | |
4206 (let ((image-name (concat newsticker-imagecache-dirname "/" | |
4207 feed-name))) | |
4208 (if (and (file-exists-p image-name) | |
4209 (time-less-p (current-time) | |
4210 (time-add (nth 5 (file-attributes image-name)) | |
4211 (seconds-to-time 86400)))) | |
4212 (newsticker--debug-msg "%s: Getting image for %s skipped" | |
4213 (format-time-string "%A, %H:%M" (current-time)) | |
4214 feed-name) | |
4215 ;; download | |
4216 (newsticker--debug-msg "%s: Getting image for %s" | |
4217 (format-time-string "%A, %H:%M" (current-time)) | |
4218 feed-name) | |
4219 (let* ((buffername (concat " *newsticker-wget-image-" feed-name "*")) | |
4220 (item (or (assoc feed-name newsticker-url-list) | |
4221 (assoc feed-name newsticker-url-list-defaults) | |
4222 (error | |
4223 "Cannot get news for %s: Check newsticker-url-list" | |
4224 feed-name))) | |
4225 (wget-arguments (or (car (cdr (cdr (cdr (cdr item))))) | |
4226 newsticker-wget-arguments))) | |
4227 (save-excursion | |
4228 (set-buffer (get-buffer-create buffername)) | |
4229 (erase-buffer) | |
4230 ;; throw an error if there is an old wget-process around | |
4231 (if (get-process feed-name) | |
4232 (error "Another wget-process is running for image %s" | |
4233 feed-name)) | |
4234 ;; start wget | |
4235 (let* ((args (append wget-arguments (list url))) | |
4236 (proc (apply 'start-process feed-name buffername | |
4237 newsticker-wget-name args))) | |
4238 (set-process-coding-system proc 'no-conversion 'no-conversion) | |
4239 (set-process-sentinel proc 'newsticker--image-sentinel))))))) | |
4240 | |
4241 (defun newsticker--image-sentinel (process event) | |
4242 "Sentinel for image-retrieving PROCESS caused by EVENT." | |
4243 (let* ((p-status (process-status process)) | |
4244 (exit-status (process-exit-status process)) | |
4245 (feed-name (process-name process))) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4246 ;; catch known errors (zombie processes, rubbish-xml, etc.) |
65468 | 4247 ;; if an error occurs the news feed is not updated! |
4248 (catch 'oops | |
4249 (unless (and (eq p-status 'exit) | |
4250 (= exit-status 0)) | |
4251 (message "%s: Error while retrieving image from %s" | |
4252 (format-time-string "%A, %H:%M" (current-time)) | |
4253 feed-name) | |
4254 (throw 'oops nil)) | |
4255 (let (image-name) | |
4256 (save-excursion | |
4257 (set-buffer (process-buffer process)) | |
4258 (setq image-name (concat newsticker-imagecache-dirname "/" | |
4259 feed-name)) | |
4260 (set-buffer-file-coding-system 'no-conversion) | |
4261 ;; make sure the cache dir exists | |
4262 (unless (file-directory-p newsticker-imagecache-dirname) | |
4263 (make-directory newsticker-imagecache-dirname)) | |
4264 ;; write and close buffer | |
4265 (let ((require-final-newline nil) | |
4266 (backup-inhibited t) | |
4267 (coding-system-for-write 'no-conversion)) | |
4268 (write-region nil nil image-name nil 'quiet)) | |
4269 (set-buffer-modified-p nil) | |
4270 (kill-buffer (current-buffer))))))) | |
4271 | |
4272 (defun newsticker--image-read (feed-name-symbol disabled) | |
4273 "Read the cached image for FEED-NAME-SYMBOL from disk. | |
4274 If DISABLED is non-nil the image will be converted to a disabled look | |
4275 \(unless `newsticker-enable-logo-manipulations' is not t\). | |
4276 Return the image." | |
4277 (let ((image-name (concat newsticker-imagecache-dirname "/" | |
4278 (symbol-name feed-name-symbol))) | |
4279 (img nil)) | |
4280 (when (file-exists-p image-name) | |
4281 (condition-case error-data | |
4282 (setq img (create-image | |
4283 image-name nil nil | |
4284 :conversion (and newsticker-enable-logo-manipulations | |
4285 disabled | |
4286 'disabled) | |
4287 :mask (and newsticker-enable-logo-manipulations | |
4288 'heuristic) | |
4289 :ascent 70)) | |
4290 (error | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4291 (message "Error: cannot create image for %s: %s" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4292 feed-name-symbol error-data)))) |
65468 | 4293 img)) |
4294 | |
4295 ;; ====================================================================== | |
4296 ;;; imenu stuff | |
4297 ;; ====================================================================== | |
4298 (defun newsticker--imenu-create-index () | |
4299 "Scan newsticker buffer and return an index for imenu." | |
4300 (save-excursion | |
4301 (goto-char (point-min)) | |
4302 (let ((index-alist nil) | |
4303 (feed-list nil) | |
4304 (go-ahead t)) | |
4305 (while go-ahead | |
4306 (let ((type (get-text-property (point) 'nt-type)) | |
4307 (title (get-text-property (point) 'nt-title))) | |
4308 (cond ((eq type 'feed) | |
4309 ;; we're on a feed heading | |
4310 (when feed-list | |
4311 (if index-alist | |
4312 (nconc index-alist (list feed-list)) | |
4313 (setq index-alist (list feed-list)))) | |
4314 (setq feed-list (list title))) | |
4315 (t | |
4316 (nconc feed-list | |
4317 (list (cons title (point))))))) | |
4318 (setq go-ahead (newsticker--buffer-goto '(item feed)))) | |
4319 (if index-alist | |
4320 (nconc index-alist (list feed-list)) | |
4321 (setq index-alist (list feed-list))) | |
4322 index-alist))) | |
4323 | |
4324 (defun newsticker--imenu-goto (name pos &rest args) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4325 "Go to item NAME at position POS and show item. |
65468 | 4326 ARGS are ignored." |
4327 (goto-char pos) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4328 ;; show headline |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4329 (newsticker--buffer-goto '(desc extra feed item)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4330 (let* ((inhibit-read-only t) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4331 (pos1 (max (point-min) (1- pos))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4332 (pos2 (max pos1 (1- (point)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4333 (inv-prop (get-text-property pos 'invisible)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4334 (org-inv-prop (get-text-property pos 'org-invisible))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4335 (when (eq org-inv-prop nil) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4336 (add-text-properties pos1 pos2 (list 'invisible nil |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4337 'org-invisible inv-prop)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4338 ;; show desc |
65468 | 4339 (newsticker-show-entry)) |
4340 | |
4341 ;; ====================================================================== | |
4342 ;;; buffer stuff | |
4343 ;; ====================================================================== | |
4344 (defun newsticker--buffer-set-uptodate (value) | |
4345 "Set the uptodate-status of the newsticker buffer to VALUE. | |
4346 The mode-line is changed accordingly." | |
4347 (setq newsticker--buffer-uptodate-p value) | |
4348 (let ((b (get-buffer "*newsticker*"))) | |
4349 (when b | |
4350 (save-excursion | |
4351 (set-buffer b) | |
4352 (if value | |
4353 (setq mode-name "Newsticker -- up to date -- ") | |
4354 (setq mode-name "Newsticker -- NEED UPDATE -- "))) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4355 (force-mode-line-update 0)))) |
65468 | 4356 |
4357 (defun newsticker--buffer-redraw () | |
75646
56945fba998d
(newsticker--insert-image): Update docstring. Insert the image directly.
Chong Yidong <cyd@stupidchicken.com>
parents:
75606
diff
changeset
|
4358 "Redraw the newsticker window." |
65468 | 4359 (if (fboundp 'force-window-update) |
4360 (force-window-update (current-buffer)) | |
4361 (redraw-frame (selected-frame))) | |
4362 (run-hooks 'newsticker-buffer-change-hook) | |
4363 (sit-for 0)) | |
4364 | |
4365 (defun newsticker--buffer-insert-all-items () | |
4366 "Insert all cached newsticker items into the current buffer. | |
4367 Keeps order of feeds as given in `newsticker-url-list' and | |
4368 `newsticker-url-list-defaults'." | |
4369 (goto-char (point-min)) | |
4370 (mapc (lambda (url-item) | |
4371 (let* ((feed-name (car url-item)) | |
4372 (feed-name-symbol (intern feed-name)) | |
4373 (feed (assoc feed-name-symbol newsticker--cache)) | |
4374 (items (cdr feed)) | |
4375 (pos (point))) | |
4376 (when feed | |
4377 ;; insert the feed description | |
4378 (mapc (lambda (item) | |
4379 (when (eq (newsticker--age item) 'feed) | |
4380 (newsticker--buffer-insert-item item | |
4381 feed-name-symbol))) | |
4382 items) | |
4383 ;;insert the items | |
4384 (mapc (lambda (item) | |
4385 (if (memq (newsticker--age item) '(new immortal old | |
4386 obsolete)) | |
4387 (newsticker--buffer-insert-item item | |
4388 feed-name-symbol))) | |
4389 items) | |
4390 (put-text-property pos (point) 'feed (car feed)) | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
4391 |
65468 | 4392 ;; insert empty line between feeds |
4393 (let ((p (point))) | |
4394 (insert "\n") | |
4395 (put-text-property p (point) 'hard t))))) | |
4396 (append newsticker-url-list newsticker-url-list-defaults)) | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
4397 |
65468 | 4398 (newsticker--buffer-set-faces (point-min) (point-max)) |
4399 (newsticker--buffer-set-invisibility (point-min) (point-max)) | |
4400 (goto-char (point-min))) | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
4401 |
65468 | 4402 (defun newsticker--buffer-insert-item (item &optional feed-name-symbol) |
4403 "Insert a news item in the current buffer. | |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
4404 Insert a formatted representation of the ITEM. The optional parameter |
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
4405 FEED-NAME-SYMBOL determines how the item is formatted and whether the |
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
4406 item-retrieval time is added as well." |
65468 | 4407 ;; insert headline |
4408 (if (eq (newsticker--age item) 'feed) | |
4409 (newsticker--buffer-do-insert-text item 'feed feed-name-symbol) | |
4410 (newsticker--buffer-do-insert-text item 'item feed-name-symbol)) | |
4411 ;; insert the description | |
4412 (newsticker--buffer-do-insert-text item 'desc feed-name-symbol)) | |
4413 | |
4414 (defun newsticker--buffer-do-insert-text (item type feed-name-symbol) | |
4415 "Actually insert contents of news item, format it, render it and all that. | |
4416 ITEM is a news item, TYPE tells which part of the item shall be inserted, | |
4417 FEED-NAME-SYMBOL tells to which feed this item belongs." | |
4418 (let* ((pos (point)) | |
4419 (format newsticker-desc-format) | |
4420 (pos-date-start nil) | |
4421 (pos-date-end nil) | |
4422 (pos-stat-start nil) | |
4423 (pos-stat-end nil) | |
4424 (pos-text-start nil) | |
4425 (pos-text-end nil) | |
4426 (pos-extra-start nil) | |
4427 (pos-extra-end nil) | |
4428 (pos-enclosure-start nil) | |
4429 (pos-enclosure-end nil) | |
4430 (age (newsticker--age item)) | |
4431 (preformatted-contents (newsticker--preformatted-contents item)) | |
4432 (preformatted-title (newsticker--preformatted-title item))) | |
4433 (cond ((and preformatted-contents | |
4434 (not (eq (aref preformatted-contents 0) ?\n));; we must | |
4435 ;; NOT have a line | |
4436 ;; break! | |
4437 (eq type 'desc)) | |
4438 (insert preformatted-contents)) | |
4439 ((and preformatted-title | |
4440 (not (eq (aref preformatted-title 0) ?\n));; we must NOT have a | |
4441 ;; line break! | |
4442 (eq type 'item)) | |
4443 (insert preformatted-title)) | |
4444 (t | |
4445 ;; item was not formatted before. | |
4446 ;; Let's go. | |
4447 (if (eq type 'item) | |
4448 (setq format newsticker-item-format) | |
4449 (if (eq type 'feed) | |
4450 (setq format newsticker-heading-format))) | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
4451 |
65468 | 4452 (while (> (length format) 0) |
4453 (let ((prefix (if (> (length format) 1) | |
4454 (substring format 0 2) | |
4455 ""))) | |
4456 (cond ((string= "%c" prefix) | |
4457 ;; contents | |
4458 (when (newsticker--desc item) | |
4459 (setq pos-text-start (point-marker)) | |
4460 (insert (newsticker--desc item)) | |
4461 (setq pos-text-end (point-marker))) | |
4462 (setq format (substring format 2))) | |
4463 ((string= "%d" prefix) | |
4464 ;; date | |
4465 (setq pos-date-start (point-marker)) | |
4466 (if (newsticker--time item) | |
4467 (insert (format-time-string newsticker-date-format | |
4468 (newsticker--time item)))) | |
4469 (setq pos-date-end (point-marker)) | |
4470 (setq format (substring format 2))) | |
4471 ((string= "%l" prefix) | |
4472 ;; logo | |
4473 (let ((disabled (cond ((eq (newsticker--age item) 'feed) | |
4474 (= (newsticker--stat-num-items | |
4475 feed-name-symbol 'new) 0)) | |
4476 (t | |
4477 (not (eq (newsticker--age item) | |
4478 'new)))))) | |
4479 (let ((img (newsticker--image-read feed-name-symbol | |
4480 disabled))) | |
4481 (when img | |
4482 (newsticker--insert-image img (car item))))) | |
4483 (setq format (substring format 2))) | |
4484 ((string= "%L" prefix) | |
4485 ;; logo or title | |
4486 (let ((disabled (cond ((eq (newsticker--age item) 'feed) | |
4487 (= (newsticker--stat-num-items | |
4488 feed-name-symbol 'new) 0)) | |
4489 (t | |
4490 (not (eq (newsticker--age item) | |
4491 'new)))))) | |
4492 (let ((img (newsticker--image-read feed-name-symbol | |
4493 disabled))) | |
4494 (if img | |
4495 (newsticker--insert-image img (car item)) | |
4496 (when (car item) | |
4497 (setq pos-text-start (point-marker)) | |
4498 (if (eq (newsticker--age item) 'feed) | |
4499 (insert (newsticker--title item)) | |
4500 ;; FIXME: This is not the "real" title! | |
4501 (insert (format "%s" | |
4502 (car (newsticker--cache-get-feed | |
4503 feed-name-symbol))))) | |
4504 (setq pos-text-end (point-marker)))))) | |
4505 (setq format (substring format 2))) | |
4506 ((string= "%s" prefix) | |
4507 ;; statistics | |
4508 (setq pos-stat-start (point-marker)) | |
4509 (if (eq (newsticker--age item) 'feed) | |
4510 (insert (newsticker--buffer-statistics | |
4511 feed-name-symbol))) | |
4512 (setq pos-stat-end (point-marker)) | |
4513 (setq format (substring format 2))) | |
4514 ((string= "%t" prefix) | |
4515 ;; title | |
4516 (when (car item) | |
4517 (setq pos-text-start (point-marker)) | |
4518 (insert (car item)) | |
4519 (setq pos-text-end (point-marker))) | |
4520 (setq format (substring format 2))) | |
4521 ((string-match "%." prefix) | |
4522 ;; unknown specifier! | |
4523 (insert prefix) | |
4524 (setq format (substring format 2))) | |
4525 ((string-match "^\\([^%]*\\)\\(.*\\)" format) ;; FIXME! | |
4526 ;; everything else | |
4527 (let ((p (point))) | |
4528 (insert (substring format | |
4529 (match-beginning 1) (match-end 1))) | |
4530 ;; in case that the format string contained newlines | |
4531 (put-text-property p (point) 'hard t)) | |
4532 (setq format (substring format (match-beginning 2))))))) | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
4533 |
65468 | 4534 ;; decode HTML if possible... |
4535 (let ((is-rendered-HTML nil)) | |
4536 (when (and newsticker-html-renderer pos-text-start pos-text-end) | |
4537 (condition-case error-data | |
4538 (save-excursion | |
4539 ;; check whether it is necessary to call html renderer | |
4540 ;; (regexp inspired by htmlr.el) | |
4541 (goto-char pos-text-start) | |
4542 (when (re-search-forward | |
4543 "</?[A-Za-z1-6]*\\|&#?[A-Za-z0-9]+;" pos-text-end t) | |
4544 ;; (message "%s" (newsticker--title item)) | |
4545 (let ((w3m-fill-column (if newsticker-use-full-width | |
4546 -1 fill-column)) | |
4547 (w3-maximum-line-length | |
4548 (if newsticker-use-full-width nil fill-column))) | |
4549 (save-excursion | |
4550 (funcall newsticker-html-renderer pos-text-start | |
4551 pos-text-end))) | |
4552 (cond ((eq newsticker-html-renderer 'w3m-region) | |
4553 (add-text-properties pos (point-max) | |
4554 (list 'keymap | |
4555 w3m-minor-mode-map))) | |
4556 ((eq newsticker-html-renderer 'w3-region) | |
4557 (add-text-properties pos (point-max) | |
4558 (list 'keymap w3-mode-map)))) | |
4559 (setq is-rendered-HTML t))) | |
4560 (error | |
4561 (message "Error: HTML rendering failed: %s, %s" | |
4562 (car error-data) (cdr error-data))))) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4563 ;; After html rendering there might be chunks of blank |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4564 ;; characters between rendered text and date, statistics or |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4565 ;; whatever. Remove it |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4566 (when (and (eq type 'item) is-rendered-HTML) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4567 (goto-char pos) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4568 (while (re-search-forward "[ \t]*\n[ \t]*" nil t) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4569 (replace-match " " nil nil)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4570 (goto-char (point-max))) |
65468 | 4571 (when (and newsticker-justification |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
4572 (memq type '(item desc)) |
65468 | 4573 (not is-rendered-HTML)) |
4574 (condition-case nil | |
4575 (let ((use-hard-newlines t)) | |
4576 (fill-region pos (point-max) newsticker-justification)) | |
4577 (error nil)))) | |
4578 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4579 ;; remove leading and trailing newlines |
65468 | 4580 (goto-char pos) |
4581 (unless (= 0 (skip-chars-forward " \t\r\n")) | |
4582 (delete-region pos (point))) | |
4583 (goto-char (point-max)) | |
4584 (let ((end (point))) | |
4585 (unless (= 0 (skip-chars-backward " \t\r\n" (1+ pos))) | |
4586 (delete-region (point) end))) | |
4587 (goto-char (point-max)) | |
4588 ;; closing newline | |
4589 (unless nil ;;(eq pos (point)) | |
4590 (insert "\n") | |
4591 (put-text-property (1- (point)) (point) 'hard t)) | |
4592 | |
4593 ;; insert enclosure element | |
4594 (when (eq type 'desc) | |
4595 (setq pos-enclosure-start (point)) | |
4596 (newsticker--buffer-insert-enclosure item) | |
4597 (setq pos-enclosure-end (point))) | |
4598 | |
4599 ;; show extra elements | |
4600 (when (eq type 'desc) | |
4601 (goto-char (point-max)) | |
4602 (setq pos-extra-start (point)) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4603 (newsticker--buffer-print-extra-elements item) |
65468 | 4604 (setq pos-extra-end (point))) |
4605 | |
4606 ;; text properties | |
4607 (when (memq type '(feed item)) | |
4608 (add-text-properties pos (1- (point)) | |
4609 (list 'mouse-face 'highlight | |
4610 'nt-link (newsticker--link item) | |
4611 'help-echo | |
4612 (format "mouse-2: visit item (%s)" | |
4613 (newsticker--link item)) | |
4614 'keymap newsticker--url-keymap)) | |
4615 (add-text-properties pos (point) | |
4616 (list 'nt-title (newsticker--title item) | |
4617 'nt-desc (newsticker--desc item)))) | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
4618 |
65468 | 4619 (add-text-properties pos (point) |
4620 (list 'nt-type type | |
4621 'nt-face type | |
4622 'nt-age age | |
4623 'nt-guid (newsticker--guid item))) | |
4624 (when (and pos-date-start pos-date-end) | |
4625 (put-text-property pos-date-start pos-date-end 'nt-face 'date)) | |
4626 (when (and pos-stat-start pos-stat-end) | |
4627 (put-text-property pos-stat-start pos-stat-end 'nt-face 'stat)) | |
4628 (when (and pos-extra-start pos-extra-end) | |
4629 (put-text-property pos-extra-start pos-extra-end | |
4630 'nt-face 'extra) | |
4631 (put-text-property pos-extra-start pos-extra-end | |
4632 'nt-type 'extra)) | |
4633 (when (and pos-enclosure-start pos-enclosure-end | |
4634 (> pos-enclosure-end pos-enclosure-start)) | |
4635 (put-text-property pos-enclosure-start (1- pos-enclosure-end) | |
4636 'nt-face 'enclosure)) | |
4637 | |
4638 ;; left margin | |
4639 ;;(unless (memq type '(feed item)) | |
4640 ;;(set-left-margin pos (1- (point)) 1)) | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
4641 |
65468 | 4642 ;; save rendered stuff |
4643 (cond ((eq type 'desc) | |
4644 ;; preformatted contents | |
4645 (newsticker--cache-set-preformatted-contents | |
4646 item (buffer-substring pos (point)))) | |
4647 ((eq type 'item) | |
4648 ;; preformatted title | |
4649 (newsticker--cache-set-preformatted-title | |
4650 item (buffer-substring pos (point))))))))) | |
4651 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4652 (defun newsticker--buffer-print-extra-elements (item) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4653 "Insert extra-elements of ITEM in a pretty form into the current buffer." |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4654 (let ((ignored-elements '(items link title description |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4655 content:encoded |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4656 dc:subject dc:date item guid |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4657 pubDate enclosure)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4658 (left-column-width 1)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4659 (mapc (lambda (extra-element) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4660 (unless (memq (car extra-element) ignored-elements) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4661 (setq left-column-width (max left-column-width |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4662 (length (symbol-name |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4663 (car extra-element))))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4664 (newsticker--extra item)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4665 (mapc (lambda (extra-element) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4666 (unless (memq (car extra-element) ignored-elements) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4667 (newsticker--buffer-do-print-extra-element extra-element |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4668 left-column-width))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4669 (newsticker--extra item)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4670 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4671 (defun newsticker--buffer-do-print-extra-element (extra-element width) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4672 "Actually print an EXTRA-ELEMENT using the given WIDTH." |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4673 (let ((name (symbol-name (car extra-element)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4674 (insert (format "%s: " name)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4675 (insert (make-string (- width (length name)) ? ))) |
65468 | 4676 (let (;;(attributes (cadr extra-element)) ;FIXME!!!! |
4677 (contents (cddr extra-element))) | |
4678 (cond ((listp contents) | |
4679 (mapc (lambda (i) | |
4680 (if (and (stringp i) | |
4681 (string-match "^http://.*" i)) | |
4682 (let ((pos (point))) | |
4683 (insert i " ") ; avoid self-reference from the | |
4684 ; nt-link thing | |
4685 (add-text-properties | |
4686 pos (point) | |
4687 (list 'mouse-face 'highlight | |
4688 'nt-link i | |
4689 'help-echo | |
4690 (format "mouse-2: visit (%s)" i) | |
4691 'keymap newsticker--url-keymap))) | |
4692 (insert (format "%s" i)))) | |
4693 contents)) | |
4694 (t | |
4695 (insert (format "%s" contents)))) | |
4696 (insert "\n"))) | |
4697 | |
4698 (defun newsticker--buffer-insert-enclosure (item) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4699 "Insert enclosure element of a news ITEM into the current buffer." |
65468 | 4700 (let ((enclosure (newsticker--enclosure item)) |
4701 (beg (point))) | |
4702 (when enclosure | |
4703 (let ((url (cdr (assoc 'url enclosure))) | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
4704 (length (string-to-number (or (cdr (assoc 'length enclosure)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
4705 "0"))) |
65468 | 4706 (type (cdr (assoc 'type enclosure)))) |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4707 (cond ((> length 1048576) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4708 (insert (format "Enclosed file (%s, %1.2f MBytes)" type |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4709 (/ length 1048576)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4710 ((> length 1024) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4711 (insert (format "Enclosed file (%s, %1.2f KBytes)" type |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4712 (/ length 1024))))) |
65468 | 4713 (add-text-properties beg (point) |
4714 (list 'mouse-face 'highlight | |
4715 'nt-link url | |
4716 'help-echo (format | |
4717 "mouse-2: visit (%s)" url) | |
4718 'keymap newsticker--url-keymap | |
4719 'nt-face 'enclosure | |
4720 'nt-type 'desc)) | |
4721 (insert "\n"))))) | |
4722 | |
4723 (defun newsticker--buffer-statistics (feed-name-symbol) | |
4724 "Return a statistic string for the feed given by FEED-NAME-SYMBOL. | |
4725 See `newsticker-statistics-format'." | |
4726 (let ((case-fold-search nil)) | |
4727 (replace-regexp-in-string | |
4728 "%a" | |
4729 (format "%d" (newsticker--stat-num-items feed-name-symbol)) | |
4730 (replace-regexp-in-string | |
4731 "%i" | |
4732 (format "%d" (newsticker--stat-num-items feed-name-symbol 'immortal)) | |
4733 (replace-regexp-in-string | |
4734 "%n" | |
4735 (format "%d" (newsticker--stat-num-items feed-name-symbol 'new)) | |
4736 (replace-regexp-in-string | |
4737 "%o" | |
4738 (format "%d" (newsticker--stat-num-items feed-name-symbol 'old)) | |
4739 (replace-regexp-in-string | |
4740 "%O" | |
4741 (format "%d" (newsticker--stat-num-items feed-name-symbol 'obsolete)) | |
4742 newsticker-statistics-format))))))) | |
4743 | |
4744 (defun newsticker--buffer-set-faces (start end) | |
4745 "Add face properties according to mark property. | |
4746 Scans the buffer between START and END." | |
4747 (save-excursion | |
4748 ;;(put-text-property start end 'face 'newsticker-default-face) | |
4749 (goto-char start) | |
4750 (let ((pos1 start) | |
4751 (pos2 1) | |
4752 (nt-face (get-text-property start 'nt-face)) | |
4753 (nt-age (get-text-property start 'nt-age))) | |
4754 (when nt-face | |
4755 (setq pos2 (next-single-property-change (point) 'nt-face)) | |
4756 (newsticker--set-face-properties pos1 pos2 nt-face nt-age) | |
4757 (setq nt-face (get-text-property pos2 'nt-face)) | |
4758 (setq pos1 pos2)) | |
4759 (while (and (setq pos2 (next-single-property-change pos1 'nt-face)) | |
4760 (<= pos2 end) | |
4761 (> pos2 pos1)) | |
4762 (newsticker--set-face-properties pos1 pos2 nt-face nt-age) | |
4763 (setq nt-face (get-text-property pos2 'nt-face)) | |
4764 (setq nt-age (get-text-property pos2 'nt-age)) | |
4765 (setq pos1 pos2))))) | |
4766 | |
4767 (defun newsticker--buffer-set-invisibility (start end) | |
4768 "Add invisibility properties according to nt-type property. | |
4769 Scans the buffer between START and END. Sets the 'invisible | |
4770 property to '(<nt-type>-<nt-age> <nt-type> <nt-age>)." | |
4771 (save-excursion | |
4772 ;; reset invisibility settings | |
4773 (put-text-property start end 'invisible nil) | |
4774 ;; let's go | |
4775 (goto-char start) | |
4776 (let ((pos1 start) | |
4777 (pos2 1) | |
4778 (nt-type (get-text-property start 'nt-type)) | |
4779 (nt-age (get-text-property start 'nt-age))) | |
4780 (when nt-type | |
4781 (setq pos2 (next-single-property-change (point) 'nt-type)) | |
4782 (put-text-property (max (point-min) pos1) (1- pos2) | |
4783 'invisible | |
4784 (list (intern | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
4785 (concat |
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
4786 (symbol-name |
65468 | 4787 (if (eq nt-type 'extra) 'desc nt-type)) |
4788 "-" | |
4789 (symbol-name nt-age))) | |
4790 nt-type | |
4791 nt-age)) | |
4792 (setq nt-type (get-text-property pos2 'nt-type)) | |
4793 (setq pos1 pos2)) | |
4794 (while (and (setq pos2 (next-single-property-change pos1 'nt-type)) | |
4795 (<= pos2 end) | |
4796 (> pos2 pos1)) | |
4797 ;; must shift one char to the left in order to handle inivisible | |
4798 ;; newlines, motion in invisible text areas and all that correctly | |
4799 (put-text-property (1- pos1) (1- pos2) | |
4800 'invisible | |
4801 (list (intern | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
4802 (concat |
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
4803 (symbol-name |
65468 | 4804 (if (eq nt-type 'extra) 'desc nt-type)) |
4805 "-" | |
4806 (symbol-name nt-age))) | |
4807 nt-type | |
4808 nt-age)) | |
4809 (setq nt-type (get-text-property pos2 'nt-type)) | |
4810 (setq nt-age (get-text-property pos2 'nt-age)) | |
4811 (setq pos1 pos2))))) | |
4812 | |
4813 (defun newsticker--set-face-properties (pos1 pos2 nt-face age) | |
4814 "Set the face for the text between the positions POS1 and POS2. | |
4815 The face is chosen according the values of NT-FACE and AGE." | |
4816 (let ((face (cond ((eq nt-face 'feed) | |
4817 'newsticker-feed-face) | |
4818 ((eq nt-face 'item) | |
4819 (cond ((eq age 'new) | |
4820 'newsticker-new-item-face) | |
4821 ((eq age 'old) | |
4822 'newsticker-old-item-face) | |
4823 ((eq age 'immortal) | |
4824 'newsticker-immortal-item-face) | |
4825 ((eq age 'obsolete) | |
4826 'newsticker-obsolete-item-face))) | |
4827 ((eq nt-face 'date) | |
4828 'newsticker-date-face) | |
4829 ((eq nt-face 'stat) | |
4830 'newsticker-statistics-face) | |
4831 ((eq nt-face 'extra) | |
4832 'newsticker-extra-face) | |
4833 ((eq nt-face 'enclosure) | |
4834 'newsticker-enclosure-face)))) | |
4835 (when face | |
4836 (put-text-property pos1 (max pos1 pos2) 'face face)))) | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
4837 |
65468 | 4838 (defun newsticker--insert-image (img string) |
75646
56945fba998d
(newsticker--insert-image): Update docstring. Insert the image directly.
Chong Yidong <cyd@stupidchicken.com>
parents:
75606
diff
changeset
|
4839 "Insert IMG with STRING at point." |
56945fba998d
(newsticker--insert-image): Update docstring. Insert the image directly.
Chong Yidong <cyd@stupidchicken.com>
parents:
75606
diff
changeset
|
4840 (insert-image img string)) |
65468 | 4841 |
4842 ;; ====================================================================== | |
4843 ;;; HTML rendering | |
4844 ;; ====================================================================== | |
4845 (defun newsticker-htmlr-render (pos1 pos2) ; | |
4846 "Replacement for `htmlr-render'. | |
4847 Renders the HTML code in the region POS1 to POS2 using htmlr." | |
4848 (let ((str (buffer-substring-no-properties pos1 pos2))) | |
4849 (delete-region pos1 pos2) | |
4850 (insert | |
4851 (with-temp-buffer | |
4852 (insert str) | |
4853 (goto-char (point-min)) | |
4854 ;; begin original htmlr-render | |
4855 (htmlr-reset) | |
4856 ;; something omitted here... | |
4857 (while (< (point) (point-max)) | |
4858 (htmlr-step)) | |
4859 ;; end original htmlr-render | |
4860 (newsticker--remove-whitespace (buffer-string)))))) | |
4861 | |
4862 ;; ====================================================================== | |
4863 ;;; Functions working on the *newsticker* buffer | |
4864 ;; ====================================================================== | |
4865 (defun newsticker--buffer-make-item-completely-visible () | |
4866 "Scroll buffer until current item is completely visible." | |
4867 (when newsticker--auto-narrow-to-feed | |
4868 (let* ((min (or (save-excursion (newsticker--buffer-beginning-of-feed)) | |
4869 (point-min))) | |
4870 (max (or (save-excursion (newsticker--buffer-end-of-feed)) | |
4871 (point-max)))) | |
4872 (narrow-to-region min max))) | |
4873 (when newsticker--auto-narrow-to-item | |
4874 (let* ((min (or (save-excursion (newsticker--buffer-beginning-of-item)) | |
4875 (point-min))) | |
4876 (max (or (save-excursion (newsticker--buffer-end-of-item)) | |
4877 (point-max)))) | |
4878 (narrow-to-region min max))) | |
4879 (sit-for 0) | |
4880 ;; do not count lines and stuff because that does not work when images | |
4881 ;; are displayed. Do it the simple way: | |
4882 (save-excursion | |
4883 (newsticker--buffer-end-of-item) | |
4884 (unless (pos-visible-in-window-p) | |
4885 (recenter -1))) | |
4886 (unless (pos-visible-in-window-p) | |
4887 (recenter 0))) | |
4888 | |
4889 (defun newsticker--buffer-get-feed-title-at-point () | |
4890 "Return feed symbol of headline at point." | |
4891 (format "%s" (or (get-text-property (point) 'feed) " "))) | |
4892 | |
4893 (defun newsticker--buffer-get-item-title-at-point () | |
4894 "Return feed symbol of headline at point." | |
4895 (format "%s" (or (get-text-property (point) 'nt-title) " "))) | |
4896 | |
4897 (defun newsticker--buffer-goto (types &optional age backwards) | |
4898 "Search next occurrence of TYPES in current buffer. | |
4899 TYPES is a list of symbols. If TYPES is found point is moved, if | |
4900 not point is left unchanged. If optional parameter AGE is not | |
4901 nil, the type AND the age must match. If BACKWARDS is t, search | |
4902 backwards." | |
4903 (let ((pos (save-excursion | |
4904 (save-restriction | |
4905 (widen) | |
4906 (catch 'found | |
4907 (let ((tpos (point))) | |
4908 (while (setq tpos | |
4909 (if backwards | |
4910 (if (eq tpos (point-min)) | |
4911 nil | |
4912 (or (previous-single-property-change | |
4913 tpos 'nt-type) | |
4914 (point-min))) | |
4915 (next-single-property-change | |
4916 tpos 'nt-type))) | |
4917 (and (memq (get-text-property tpos 'nt-type) types) | |
4918 (or (not age) | |
4919 (eq (get-text-property tpos 'nt-age) age)) | |
4920 (throw 'found tpos))))))))) | |
4921 (when pos | |
4922 (goto-char pos)) | |
4923 pos)) | |
4924 | |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
4925 (defun newsticker--buffer-hideshow (mark-age onoff) |
65468 | 4926 "Hide or show items of type MARK-AGE. |
4927 If ONOFF is nil the item is hidden, otherwise it is shown." | |
4928 (if onoff | |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
4929 (remove-from-invisibility-spec mark-age) |
65468 | 4930 (add-to-invisibility-spec mark-age))) |
4931 | |
4932 (defun newsticker--buffer-beginning-of-item () | |
4933 "Move point to the beginning of the item at point. | |
4934 Return new position." | |
4935 (if (bobp) | |
4936 (point) | |
4937 (let ((type (get-text-property (point) 'nt-type)) | |
4938 (typebefore (get-text-property (1- (point)) 'nt-type))) | |
4939 (if (and (memq type '(item feed)) | |
4940 (not (eq type typebefore))) | |
4941 (point) | |
4942 (newsticker--buffer-goto '(item feed) nil t) | |
4943 (point))))) | |
4944 | |
4945 (defun newsticker--buffer-beginning-of-feed () | |
4946 "Move point to the beginning of the feed at point. | |
4947 Return new position." | |
4948 (if (bobp) | |
4949 (point) | |
4950 (let ((type (get-text-property (point) 'nt-type)) | |
4951 (typebefore (get-text-property (1- (point)) 'nt-type))) | |
4952 (if (and (memq type '(feed)) | |
4953 (not (eq type typebefore))) | |
4954 (point) | |
4955 (newsticker--buffer-goto '(feed) nil t) | |
4956 (point))))) | |
4957 | |
4958 (defun newsticker--buffer-end-of-item () | |
4959 "Move point to the end of the item at point. | |
4960 Take care: end of item is at the end of its last line!" | |
4961 (when (newsticker--buffer-goto '(item feed nil)) | |
4962 (point))) | |
4963 | |
4964 (defun newsticker--buffer-end-of-feed () | |
4965 "Move point to the end of the last item of the feed at point. | |
4966 Take care: end of item is at the end of its last line!" | |
4967 (when (newsticker--buffer-goto '(feed nil)) | |
4968 (backward-char 1) | |
4969 (point))) | |
4970 | |
4971 ;; ====================================================================== | |
4972 ;;; manipulation of ticker text | |
4973 ;; ====================================================================== | |
4974 (defun newsticker--ticker-text-setup () | |
4975 "Build the ticker text which is scrolled or flashed in the echo area." | |
4976 ;; reset scrollable text | |
4977 (setq newsticker--scrollable-text "") | |
4978 (setq newsticker--item-list nil) | |
4979 (setq newsticker--item-position 0) | |
4980 ;; build scrollable text from cache data | |
4981 (let ((have-something nil)) | |
4982 (mapc | |
4983 (lambda (feed) | |
4984 (let ((feed-name (symbol-name (car feed)))) | |
4985 (let ((num-new (newsticker--stat-num-items (car feed) 'new)) | |
4986 (num-old (newsticker--stat-num-items (car feed) 'old)) | |
4987 (num-imm (newsticker--stat-num-items (car feed) 'immortal)) | |
4988 (num-obs (newsticker--stat-num-items (car feed) 'obsolete))) | |
4989 (when (or (> num-new 0) | |
4990 (and (> num-old 0) | |
4991 (not newsticker-hide-old-items-in-echo-area)) | |
4992 (and (> num-imm 0) | |
4993 (not newsticker-hide-immortal-items-in-echo-area)) | |
4994 (and (> num-obs 0) | |
4995 (not newsticker-hide-obsolete-items-in-echo-area))) | |
4996 (setq have-something t) | |
4997 (mapc | |
4998 (lambda (item) | |
4999 (let ((title (replace-regexp-in-string | |
5000 "[\r\n]+" " " | |
5001 (newsticker--title item))) | |
5002 (age (newsticker--age item))) | |
5003 (unless (string= title newsticker--error-headline) | |
5004 (when | |
5005 (or (eq age 'new) | |
5006 (and (eq age 'old) | |
5007 (not newsticker-hide-old-items-in-echo-area)) | |
5008 (and (eq age 'obsolete) | |
5009 (not | |
5010 newsticker-hide-obsolete-items-in-echo-area)) | |
5011 (and (eq age 'immortal) | |
5012 (not | |
5013 newsticker-hide-immortal-items-in-echo-area))) | |
5014 (setq title (newsticker--remove-whitespace title)) | |
5015 ;; add to flash list | |
5016 (add-to-list 'newsticker--item-list | |
5017 (concat feed-name ": " title) t) | |
5018 ;; and to the scrollable text | |
5019 (setq newsticker--scrollable-text | |
5020 (concat newsticker--scrollable-text | |
5021 " " feed-name ": " title " +++")))))) | |
5022 (cdr feed)))))) | |
5023 newsticker--cache) | |
5024 (when have-something | |
5025 (setq newsticker--scrollable-text | |
5026 (concat "+++ " | |
5027 (format-time-string "%A, %H:%M" | |
5028 newsticker--latest-update-time) | |
5029 " ++++++" newsticker--scrollable-text))))) | |
5030 | |
5031 (defun newsticker--ticker-text-remove (feed title) | |
5032 "Remove the item of FEED with TITLE from the ticker text." | |
5033 ;; reset scrollable text | |
5034 (setq newsticker--item-position 0) | |
5035 (let ((feed-name (symbol-name feed)) | |
5036 (t-title (replace-regexp-in-string "[\r\n]+" " " title))) | |
5037 ;; remove from flash list | |
5038 (setq newsticker--item-list (remove (concat feed-name ": " t-title) | |
5039 newsticker--item-list)) | |
5040 ;; and from the scrollable text | |
5041 (setq newsticker--scrollable-text | |
5042 (replace-regexp-in-string | |
5043 (regexp-quote (concat " " feed-name ": " t-title " +++")) | |
5044 "" | |
5045 newsticker--scrollable-text)) | |
5046 (if (string-match (concat "^\\+\\+\\+ [A-Z][a-z]+, " | |
5047 "[012]?[0-9]:[0-9][0-9] \\+\\+\\+\\+\\+\\+$") | |
5048 newsticker--scrollable-text) | |
5049 (setq newsticker--scrollable-text "")))) | |
5050 | |
5051 ;; ====================================================================== | |
5052 ;;; manipulation of cached data | |
5053 ;; ====================================================================== | |
5054 (defun newsticker--cache-set-preformatted-contents (item contents) | |
5055 "Set preformatted contents of ITEM to CONTENTS." | |
5056 (if (nthcdr 6 item) | |
5057 (setcar (nthcdr 6 item) contents) | |
5058 (setcdr (nthcdr 5 item) (list contents)))) | |
5059 | |
5060 (defun newsticker--cache-set-preformatted-title (item title) | |
5061 "Set preformatted title of ITEM to TITLE." | |
5062 (if (nthcdr 7 item) | |
5063 (setcar (nthcdr 7 item) title) | |
5064 (setcdr (nthcdr 6 item) title))) | |
5065 | |
5066 (defun newsticker--cache-replace-age (data feed old-age new-age) | |
5067 "Mark all items in DATA in FEED which carry age OLD-AGE with NEW-AGE. | |
5068 If FEED is 'any it applies to all feeds. If OLD-AGE is 'any, | |
5069 all marks are replaced by NEW-AGE. Removes all pre-formatted contents." | |
5070 (mapc (lambda (a-feed) | |
5071 (when (or (eq feed 'any) | |
5072 (eq (car a-feed) feed)) | |
5073 (let ((items (cdr a-feed))) | |
5074 (mapc (lambda (item) | |
5075 (when (or (eq old-age 'any) | |
5076 (eq (newsticker--age item) old-age)) | |
5077 (setcar (nthcdr 4 item) new-age) | |
5078 (newsticker--do-forget-preformatted item))) | |
5079 items)))) | |
5080 data) | |
5081 data) | |
5082 | |
5083 (defun newsticker--cache-mark-expired (data feed old-age new-age time) | |
5084 "Mark all expired entries. | |
5085 This function sets the age entries in DATA in the feed FEED. If | |
5086 an item's age is OLD-AGE it is set to NEW-AGE if the item is | |
5087 older than TIME." | |
5088 (mapc | |
5089 (lambda (a-feed) | |
5090 (when (or (eq feed 'any) | |
5091 (eq (car a-feed) feed)) | |
5092 (let ((items (cdr a-feed))) | |
5093 (mapc | |
5094 (lambda (item) | |
5095 (when (eq (newsticker--age item) old-age) | |
5096 (let ((exp-time (time-add (newsticker--time item) | |
5097 (seconds-to-time time)))) | |
5098 (when (time-less-p exp-time (current-time)) | |
5099 (newsticker--debug-msg | |
5100 "Item `%s' from %s has expired on %s" | |
5101 (newsticker--title item) | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
5102 (format-time-string "%Y-%02m-%d, %H:%M" |
65468 | 5103 (newsticker--time item)) |
5104 (format-time-string "%Y-%02m-%d, %H:%M" exp-time)) | |
5105 (setcar (nthcdr 4 item) new-age))))) | |
5106 items)))) | |
5107 data) | |
5108 data) | |
5109 | |
5110 (defun newsticker--cache-contains (data feed title desc link age | |
5111 &optional guid) | |
5112 "Check DATA whether FEED contains an item with the given properties. | |
5113 This function returns the contained item or nil if it is not | |
5114 contained. | |
5115 The properties which are checked are TITLE, DESC, LINK, AGE, and | |
5116 GUID. In general all properties must match in order to return a | |
5117 certain item, except for the following cases. | |
5118 | |
5119 If AGE equals 'feed the TITLE, DESCription and LINK do not | |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
5120 matter. If DESC is nil it is ignored as well. If |
65468 | 5121 `newsticker-desc-comp-max' is non-nil, only the first |
5122 `newsticker-desc-comp-max' characters of DESC are taken into | |
5123 account. | |
5124 | |
5125 If GUID is non-nil it is sufficient to match this value, and the | |
5126 other properties are ignored." | |
5127 (condition-case nil | |
5128 (catch 'found | |
5129 (when (and desc newsticker-desc-comp-max | |
5130 (> (length desc) newsticker-desc-comp-max)) | |
5131 (setq desc (substring desc 0 newsticker-desc-comp-max))) | |
5132 (mapc | |
5133 (lambda (this-feed) | |
5134 (when (eq (car this-feed) feed) | |
5135 (mapc (lambda (anitem) | |
5136 (when (or | |
5137 ;; global unique id can match | |
5138 (and guid | |
5139 (string= guid (newsticker--guid anitem))) | |
5140 ;; or title, desc, etc. | |
5141 (and | |
5142 ;;(or (not (eq age 'feed)) | |
5143 ;; (eq (newsticker--age anitem) 'feed)) | |
5144 (string= (newsticker--title anitem) | |
5145 title) | |
5146 (or (not link) | |
5147 (string= (newsticker--link anitem) | |
5148 link)) | |
5149 (or (not desc) | |
5150 (if (and desc newsticker-desc-comp-max | |
5151 (> (length (newsticker--desc anitem)) | |
5152 newsticker-desc-comp-max)) | |
5153 (string= (substring | |
5154 (newsticker--desc anitem) | |
5155 0 newsticker-desc-comp-max) | |
5156 desc) | |
5157 (string= (newsticker--desc anitem) | |
5158 desc))))) | |
5159 (throw 'found anitem))) | |
5160 (cdr this-feed)))) | |
5161 data) | |
5162 nil) | |
5163 (error nil))) | |
5164 | |
5165 (defun newsticker--cache-add (data feed-name-symbol title desc link time age | |
5166 position extra-elements | |
5167 &optional updated-age updated-time | |
5168 preformatted-contents | |
5169 preformatted-title) | |
5170 "Add another item to cache data. | |
5171 Add to DATA in the FEED-NAME-SYMBOL an item with TITLE, DESC, | |
5172 LINK, TIME, AGE, POSITION, and EXTRA-ELEMENTS. If this item is | |
5173 contained already, its mark is set to UPDATED-AGE, its time is | |
5174 set to UPDATED-TIME, and its pre-formatted contents is set to | |
5175 PREFORMATTED-CONTENTS and PREFORMATTED-TITLE. Returns the age | |
5176 which the item got." | |
5177 (let ((item (newsticker--cache-contains data feed-name-symbol title | |
5178 desc link age))) | |
5179 (if item | |
5180 ;; does exist already -- change age, update time and position | |
5181 (progn | |
5182 (if (nthcdr 5 item) | |
5183 (setcar (nthcdr 5 item) position) | |
5184 (setcdr (nthcdr 4 item) (list position))) | |
5185 (setcar (nthcdr 4 item) updated-age) | |
5186 (if updated-time | |
5187 (setcar (nthcdr 3 item) updated-time)) | |
5188 ;; replace cached pre-formatted contents | |
5189 (newsticker--cache-set-preformatted-contents | |
5190 item preformatted-contents) | |
5191 (newsticker--cache-set-preformatted-title | |
5192 item preformatted-title)) | |
5193 ;; did not exist or age equals 'feed-name-symbol | |
5194 (catch 'found | |
5195 (mapc (lambda (this-feed) | |
5196 (when (eq (car this-feed) feed-name-symbol) | |
5197 (setcdr this-feed (nconc (cdr this-feed) | |
5198 (list (list title desc link | |
5199 time age position | |
5200 preformatted-contents | |
5201 preformatted-title | |
5202 extra-elements)))) | |
5203 (throw 'found this-feed))) | |
5204 data) | |
5205 ;; the feed is not contained | |
5206 (add-to-list 'data (list feed-name-symbol | |
5207 (list title desc link time age position | |
5208 preformatted-contents | |
5209 preformatted-title | |
5210 extra-elements)) | |
5211 t)))) | |
5212 data) | |
5213 | |
5214 (defun newsticker--cache-remove (data feed-symbol age) | |
5215 "Remove all entries from DATA in the feed FEED-SYMBOL with AGE. | |
5216 FEED-SYMBOL may be 'any. Entries from old feeds, which are no longer in | |
5217 `newsticker-url-list' or `newsticker-url-list-defaults', are removed as | |
5218 well." | |
5219 (let* ((pos data) | |
5220 (feed (car pos)) | |
5221 (last-pos nil)) | |
5222 (while feed | |
5223 (if (or (assoc (symbol-name (car feed)) newsticker-url-list) | |
5224 (assoc (symbol-name (car feed)) newsticker-url-list-defaults)) | |
5225 ;; feed is still valid=active | |
5226 ;; (message "Keeping feed %s" (car feed)) | |
5227 (if (or (eq feed-symbol 'any) | |
5228 (eq feed-symbol (car feed))) | |
5229 (let* ((item-pos (cdr feed)) | |
5230 (item (car item-pos)) | |
5231 (prev-pos nil)) | |
5232 (while item | |
5233 ;;(message "%s" (car item)) | |
5234 (if (eq age (newsticker--age item)) | |
5235 ;; remove this item | |
5236 (progn | |
5237 ;;(message "Removing item %s" (car item)) | |
5238 (if prev-pos | |
5239 (setcdr prev-pos (cdr item-pos)) | |
5240 (setcdr feed (cdr item-pos)))) | |
5241 ;;(message "Keeping item %s" (car item)) | |
5242 (setq prev-pos item-pos)) | |
5243 (setq item-pos (cdr item-pos)) | |
5244 (setq item (car item-pos))))) | |
5245 ;; feed is not active anymore | |
5246 ;; (message "Removing feed %s" (car feed)) | |
5247 (if last-pos | |
5248 (setcdr last-pos (cdr pos)) | |
5249 (setq data (cdr pos)))) | |
5250 (setq last-pos pos) | |
5251 (setq pos (cdr pos)) | |
5252 (setq feed (car pos))))) | |
5253 | |
5254 ;; ====================================================================== | |
5255 ;;; Sorting | |
5256 ;; ====================================================================== | |
5257 (defun newsticker--cache-item-compare-by-time (item1 item2) | |
5258 "Compare two news items ITEM1 and ITEM2 by comparing their time values." | |
5259 (catch 'result | |
5260 (let ((age1 (newsticker--age item1)) | |
5261 (age2 (newsticker--age item2))) | |
5262 (if (not (eq age1 age2)) | |
5263 (cond ((eq age1 'obsolete) | |
5264 (throw 'result nil)) | |
5265 ((eq age2 'obsolete) | |
5266 (throw 'result t))))) | |
5267 (let* ((time1 (newsticker--time item1)) | |
5268 (time2 (newsticker--time item2))) | |
5269 (cond ((< (nth 0 time1) (nth 0 time2)) | |
5270 nil) | |
5271 ((> (nth 0 time1) (nth 0 time2)) | |
5272 t) | |
5273 ((< (nth 1 time1) (nth 1 time2)) | |
5274 nil) | |
5275 ((> (nth 1 time1) (nth 1 time2)) | |
5276 t) | |
5277 ((< (or (nth 2 time1) 0) (or (nth 2 time2) 0)) | |
5278 nil) | |
5279 ((> (or (nth 2 time1) 0) (or (nth 2 time2) 0)) | |
5280 t) | |
5281 (t | |
5282 nil))))) | |
5283 | |
5284 (defun newsticker--cache-item-compare-by-title (item1 item2) | |
5285 "Compare ITEM1 and ITEM2 by comparing their titles." | |
5286 (catch 'result | |
5287 (let ((age1 (newsticker--age item1)) | |
5288 (age2 (newsticker--age item2))) | |
5289 (if (not (eq age1 age2)) | |
5290 (cond ((eq age1 'obsolete) | |
5291 (throw 'result nil)) | |
5292 ((eq age2 'obsolete) | |
5293 (throw 'result t))))) | |
5294 (string< (newsticker--title item1) (newsticker--title item2)))) | |
5295 | |
5296 (defun newsticker--cache-item-compare-by-position (item1 item2) | |
5297 "Compare ITEM1 and ITEM2 by comparing their original positions." | |
5298 (catch 'result | |
5299 (let ((age1 (newsticker--age item1)) | |
5300 (age2 (newsticker--age item2))) | |
5301 (if (not (eq age1 age2)) | |
5302 (cond ((eq age1 'obsolete) | |
5303 (throw 'result nil)) | |
5304 ((eq age2 'obsolete) | |
5305 (throw 'result t))))) | |
5306 (< (or (newsticker--pos item1) 0) (or (newsticker--pos item2) 0)))) | |
5307 | |
5308 (defun newsticker--cache-sort () | |
5309 "Sort the newsticker cache data." | |
5310 (let ((sort-fun (cond ((eq newsticker-sort-method 'sort-by-time) | |
5311 'newsticker--cache-item-compare-by-time) | |
5312 ((eq newsticker-sort-method 'sort-by-title) | |
5313 'newsticker--cache-item-compare-by-title) | |
5314 ((eq newsticker-sort-method 'sort-by-original-order) | |
5315 'newsticker--cache-item-compare-by-position)))) | |
5316 (mapc (lambda (feed-list) | |
5317 (setcdr feed-list (sort (cdr feed-list) | |
5318 sort-fun))) | |
5319 newsticker--cache))) | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
5320 |
65468 | 5321 (defun newsticker--cache-update (&optional save) |
5322 "Update newsticker cache file. | |
5323 If optional argument SAVE is not nil the cache file is saved to disk." | |
5324 (save-excursion | |
5325 (let ((coding-system-for-write 'utf-8) | |
5326 (buf (find-file-noselect newsticker-cache-filename))) | |
5327 (when buf | |
5328 (set-buffer buf) | |
5329 (setq buffer-undo-list t) | |
5330 (erase-buffer) | |
5331 (insert ";; -*- coding: utf-8 -*-\n") | |
5332 (insert (prin1-to-string newsticker--cache)) | |
5333 (when save | |
5334 (save-buffer)))))) | |
5335 | |
5336 (defun newsticker--cache-get-feed (feed) | |
5337 "Return the cached data for the feed FEED. | |
5338 FEED is a symbol!" | |
5339 (assoc feed newsticker--cache)) | |
5340 | |
5341 ;; ====================================================================== | |
5342 ;;; Statistics | |
5343 ;; ====================================================================== | |
5344 (defun newsticker--stat-num-items (feed &optional age) | |
5345 "Return number of items in the given FEED which have the given AGE. | |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
5346 If AGE is nil, the total number of items is returned." |
65468 | 5347 (let ((items (cdr (newsticker--cache-get-feed feed))) |
5348 (num 0)) | |
5349 (while items | |
5350 (if age | |
5351 (if (eq (newsticker--age (car items)) age) | |
5352 (setq num (1+ num))) | |
5353 (if (memq (newsticker--age (car items)) '(new old immortal obsolete)) | |
5354 (setq num (1+ num)))) | |
5355 (setq items (cdr items))) | |
5356 num)) | |
5357 | |
5358 ;; ====================================================================== | |
5359 ;;; OPML | |
5360 ;; ====================================================================== | |
5361 (defun newsticker-opml-export () | |
5362 "OPML subscription export. | |
5363 Export subscriptions to a buffer in OPML Format." | |
5364 (interactive) | |
5365 (with-current-buffer (get-buffer-create "*OPML Export*") | |
5366 (set-buffer-file-coding-system 'utf-8) | |
5367 (insert (concat | |
5368 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" | |
5369 "<!-- OPML generated by Emacs newsticker.el -->\n" | |
5370 "<opml version=\"1.0\">\n" | |
5371 " <head>\n" | |
5372 " <title>mySubscriptions</title>\n" | |
5373 " <dateCreated>" (format-time-string "%a, %d %b %Y %T %z") | |
5374 "</dateCreated>\n" | |
5375 " <ownerEmail>" user-mail-address "</ownerEmail>\n" | |
5376 " <ownerName>" (user-full-name) "</ownerName>\n" | |
5377 " </head>\n" | |
5378 " <body>\n")) | |
5379 (mapc (lambda (sub) | |
5380 (insert " <outline text=\"") | |
5381 (insert (newsticker--title sub)) | |
5382 (insert "\" xmlUrl=\"") | |
5383 (insert (cadr sub)) | |
5384 (insert "\"/>\n")) | |
5385 (append newsticker-url-list newsticker-url-list-defaults)) | |
5386 (insert " </body>\n</opml>\n")) | |
5387 (pop-to-buffer "*OPML Export*") | |
5388 (when (fboundp 'sgml-mode) | |
5389 (sgml-mode))) | |
5390 | |
5391 (defun newsticker-opml-import (filename) | |
5392 "Import OPML data from FILENAME." | |
5393 (interactive "fOPML file: ") | |
5394 (set-buffer (find-file-noselect filename)) | |
5395 (goto-char (point-min)) | |
5396 (let* ((node-list (xml-parse-region (point-min) (point-max))) | |
5397 (body (car (xml-get-children (car node-list) 'body))) | |
5398 (outlines (xml-get-children body 'outline))) | |
5399 (mapc (lambda (outline) | |
5400 (let ((name (xml-get-attribute outline 'text)) | |
5401 (url (xml-get-attribute outline 'xmlUrl))) | |
5402 (add-to-list 'newsticker-url-list | |
5403 (list name url nil nil nil) t))) | |
5404 outlines)) | |
5405 (customize-variable 'newsticker-url-list)) | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
5406 |
65468 | 5407 ;; ====================================================================== |
5408 ;;; Auto marking | |
5409 ;; ====================================================================== | |
5410 (defun newsticker--run-auto-mark-filter (feed item) | |
5411 "Automatically mark an item as old or immortal. | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5412 This function checks the variable `newsticker-auto-mark-filter-list' |
65468 | 5413 for an entry that matches FEED and ITEM." |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5414 (let ((case-fold-search t)) |
65468 | 5415 (mapc (lambda (filter) |
5416 (let ((filter-feed (car filter)) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5417 (pattern-list (cadr filter))) |
65468 | 5418 (when (string-match filter-feed feed) |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5419 (newsticker--do-run-auto-mark-filter item pattern-list)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5420 newsticker-auto-mark-filter-list))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5421 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5422 (defun newsticker--do-run-auto-mark-filter (item list) |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
5423 "Actually compare ITEM against the pattern-LIST |
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
5424 \(from `newsticker-auto-mark-filter-list')." |
65468 | 5425 (mapc (lambda (pattern) |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5426 (let ((age (nth 0 pattern)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5427 (place (nth 1 pattern)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5428 (regexp (nth 2 pattern)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5429 (title (newsticker--title item)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5430 (desc (newsticker--desc item))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5431 (when (or (eq place 'title) (eq place 'all)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5432 (when (and title (string-match regexp title)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5433 (newsticker--debug-msg "Auto-marking as %s: `%s'" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5434 age (newsticker--title item)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5435 (setcar (nthcdr 4 item) age))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5436 (when (or (eq place 'description) (eq place 'all)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5437 (when (and desc (string-match regexp desc)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5438 (newsticker--debug-msg "Auto-marking as %s: `%s'" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5439 age (newsticker--title item)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5440 (setcar (nthcdr 4 item) age))))) |
65468 | 5441 list)) |
5442 | |
5443 | |
5444 ;; ====================================================================== | |
5445 ;;; hook samples | |
5446 ;; ====================================================================== | |
5447 (defun newsticker-new-item-functions-sample (feed item) | |
5448 "Demonstrate the use of the `newsticker-new-item-functions' hook. | |
5449 This function just prints out the values of the FEED and title of the ITEM." | |
5450 (message (concat "newsticker-new-item-functions-sample: feed=`%s', " | |
5451 "title=`%s'") | |
5452 feed (newsticker--title item))) | |
5453 | |
5454 (defun newsticker-download-images (feed item) | |
5455 "Download the first image. | |
5456 If FEED equals \"imagefeed\" download the first image URL found | |
5457 in the description=contents of ITEM to the directory | |
5458 \"~/tmp/newsticker/FEED/TITLE\" where TITLE is the title of the item." | |
5459 (when (string= feed "imagefeed") | |
5460 (let ((title (newsticker--title item)) | |
5461 (desc (newsticker--desc item))) | |
5462 (when (string-match "<img src=\"\\(http://[^ \"]+\\)\"" desc) | |
5463 (let ((url (substring desc (match-beginning 1) (match-end 1))) | |
5464 (temp-dir (concat "~/tmp/newsticker/" feed "/" title)) | |
5465 (org-dir default-directory)) | |
5466 (unless (file-directory-p temp-dir) | |
5467 (make-directory temp-dir t)) | |
5468 (cd temp-dir) | |
5469 (message "Getting image %s" url) | |
5470 (apply 'start-process "wget-image" | |
5471 " *newsticker-wget-download-images*" | |
5472 newsticker-wget-name | |
5473 (list url)) | |
5474 (cd org-dir)))))) | |
5475 | |
5476 (defun newsticker-download-enclosures (feed item) | |
5477 "In all FEEDs download the enclosed object of the news ITEM. | |
5478 The object is saved to the directory \"~/tmp/newsticker/FEED/TITLE\", which | |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
5479 is created if it does not exist. TITLE is the title of the news |
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
5480 item. Argument FEED is ignored. |
65468 | 5481 This function is suited for adding it to `newsticker-new-item-functions'." |
5482 (let ((title (newsticker--title item)) | |
5483 (enclosure (newsticker--enclosure item))) | |
5484 (when enclosure | |
5485 (let ((url (cdr (assoc 'url enclosure))) | |
5486 (temp-dir (concat "~/tmp/newsticker/" feed "/" title)) | |
5487 (org-dir default-directory)) | |
5488 (unless (file-directory-p temp-dir) | |
5489 (make-directory temp-dir t)) | |
5490 (cd temp-dir) | |
5491 (message "Getting enclosure %s" url) | |
5492 (apply 'start-process "wget-enclosure" | |
5493 " *newsticker-wget-download-enclosures*" | |
5494 newsticker-wget-name | |
5495 (list url)) | |
5496 (cd org-dir))))) | |
5497 | |
5498 | |
5499 (provide 'newsticker) | |
5500 | |
65481 | 5501 ;; arch-tag: ab761dfa-67bc-4207-bc64-4307271dc381 |
65468 | 5502 ;;; newsticker.el ends here |