Mercurial > emacs
annotate lisp/net/newsticker.el @ 76414:439b3ff34422
** md5i@cs.cmu.edu, Feb 20: move-end-of-line in comint buffers
Postphoned to post Emacs 22.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Fri, 09 Mar 2007 14:57:38 +0000 |
parents | 404cd4b4fb09 |
children | 60f8467b3790 07774e5c3ff5 db735800b535 |
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 |
16 ;; This program is free software; you can redistribute it and/or modify | |
17 ;; it under the terms of the GNU General Public License as published by | |
18 ;; the Free Software Foundation; either version 2 of the License, or (at | |
19 ;; your option) any later version. | |
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 | |
65638
e274642bf5d5
Update FSF street address; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65617
diff
changeset
|
27 ;; along with this program; if not, write to the Free Software Foundation, |
e274642bf5d5
Update FSF street address; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
65617
diff
changeset
|
28 ;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
65468 | 29 |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
30 (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
|
31 |
65468 | 32 ;; ====================================================================== |
33 ;;; Commentary: | |
34 | |
35 ;; Overview | |
36 ;; -------- | |
37 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
38 ;; 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
|
39 ;; 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
|
40 ;; 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
|
41 ;; corresponding articles in a web browser. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
42 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
43 ;; 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
|
44 ;; 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
|
45 ;; should work with the following RSS formats: |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
46 ;; * RSS 0.91 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
47 ;; (see http://backend.userland.com/rss091 or |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
48 ;; 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
|
49 ;; * RSS 0.92 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
50 ;; (see http://backend.userland.com/rss092) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
51 ;; * RSS 1.0 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
52 ;; (see http://purl.org/rss/1.0/spec) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
53 ;; * RSS 2.0 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
54 ;; (see http://blogs.law.harvard.edu/tech/rss) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
55 ;; as well as the following Atom formats: |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
56 ;; * Atom 0.3 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
57 ;; * Atom 1.0 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
58 ;; (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
|
59 ;; 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
|
60 ;; aggregator", and "Feed Reader". |
65468 | 61 |
62 ;; Newsticker provides several commands for reading headlines, navigating | |
63 ;; 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
|
64 ;; etc. Headlines can be displayed as plain text or as rendered HTML. |
65468 | 65 |
66 ;; Headlines can be displayed in the echo area, either scrolling like | |
67 ;; messages in a stock-quote ticker, or just changing. | |
68 | |
69 ;; Newsticker allows for automatic processing of headlines by providing | |
70 ;; hooks and (sample) functions for automatically downloading images and | |
71 ;; enclosed files (as delivered by podcasts, e.g.). | |
72 | |
73 ;; Requirements | |
74 ;; ------------ | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
75 ;; 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
|
76 ;; 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
|
77 ;; Emacs. If you are using XEmacs you want to get the `net-utils' package |
65468 | 78 ;; which contains `xml.el' for XEmacs. |
79 | |
80 ;; 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
|
81 ;; prints them to stdout. By default Newsticker will use wget for this |
65468 | 82 ;; task. |
83 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
84 ;; Installation |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
85 ;; ------------ |
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 ;; 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
|
88 ;; 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
|
89 ;; 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
|
90 ;; following line to your Emacs startup file (`~/.emacs'). |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
91 ;; (add-to-list 'load-path "/path/to/newsticker/") |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
92 ;; (autoload 'newsticker-start "newsticker" "Emacs Newsticker" t) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
93 ;; (autoload 'newsticker-show-news "newsticker" "Emacs Newsticker" t) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
94 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
95 ;; 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
|
96 ;; 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
|
97 ;; (`~/.emacs'). |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
98 ;; (add-hook 'newsticker-mode-hook 'imenu-add-menubar-index) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
99 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
100 ;; That's it. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
101 |
65468 | 102 ;; Usage |
103 ;; ----- | |
104 ;; 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
|
105 ;; 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
|
106 ;; asynchronous download of headlines. The modeline in the `*newsticker*' |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
107 ;; buffer informs whenever new headlines have arrived. Clicking |
65468 | 108 ;; mouse-button 2 or pressing RET in this buffer on a headline will call |
109 ;; browse-url to load the corresponding news story in your favourite web | |
110 ;; browser. | |
111 | |
112 ;; 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
|
113 ;; with the command newsticker-start-ticker. It can be stopped with |
65468 | 114 ;; newsticker-stop-ticker. |
115 | |
116 ;; 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
|
117 ;; command newsticker-start. Calling newsticker-stop will stop the |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
118 ;; periodic download, but will call newsticker-stop-ticker as well. |
65468 | 119 |
120 ;; Configuration | |
121 ;; ------------- | |
122 ;; All Newsticker options are customizable, i.e. they can be changed with | |
123 ;; Emacs customization methods: Call the command customize-group and enter | |
124 ;; `newsticker' for the customization group. | |
125 | |
126 ;; All Newsticker options have reasonable default values, so that in most | |
127 ;; cases it is not necessary to customize settings before starting | |
128 ;; Newsticker for the first time. | |
129 | |
130 ;; Newsticker options are organized in the following groups. | |
131 | |
132 ;; * newsticker-feed contains options that define which news | |
133 ;; feeds are retrieved and how this is done. | |
134 ;; o newsticker-url-list defines the list of headlines which are | |
135 ;; retrieved. | |
136 ;; o newsticker-retrieval-interval defines how often headlines are | |
137 ;; retrieved. | |
138 ;; * newsticker-headline-processing contains options that define how the | |
139 ;; retrieved headlines are processed. | |
140 ;; o newsticker-keep-obsolete-items decides whether unread headlines that | |
141 ;; have been removed from the feed are kept in the Newsticker cache. | |
142 ;; * 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
|
143 ;; reading news headlines is formatted. |
65468 | 144 ;; o newsticker-item-format defines how the title of a headline is |
145 ;; formatted. | |
146 ;; * newsticker-ticker contains options that define how headlines are shown | |
147 ;; in the echo area. | |
148 ;; o newsticker-display-interval and newsticker-scroll-smoothly define | |
149 ;; how headlines are shown in the echo area. | |
150 ;; * newsticker-hooks contains options for hooking other Emacs commands to | |
151 ;; newsticker functions. | |
152 ;; 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
|
153 ;; headlines. See `newsticker-download-images', and |
65468 | 154 ;; `newsticker-download-enclosures' for sample functions. |
155 ;; * newsticker-miscellaneous contains other Newsticker options. | |
156 | |
157 ;; Please have a look at the customization buffers for the complete list of | |
158 ;; options. | |
159 | |
160 ;; Remarks | |
161 ;; ------- | |
162 ;; This newsticker is designed do its job silently in the background | |
163 ;; without disturbing you. However, it is probably impossible to prevent | |
164 ;; such a tool from slightly attenuating your Editor's responsiveness every | |
165 ;; once in a while. | |
166 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
167 ;; Byte-compiling newsticker.el is recommended. |
65468 | 168 |
169 ;; ====================================================================== | |
170 ;;; History: | |
171 | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
172 ;; 1.10 (2007-01-29) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
173 ;; * Bugfixes mostly: `newsticker--decode-iso8601-date', |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
174 ;; `newsticker--sentinel', and others. |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
175 ;; * Renamed `newsticker--retrieval-timer-list' to |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
176 ;; `newsticker-retrieval-timer-list'. Removed |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
177 ;; `newsticker-running-p' -- check newsticker-retrieval-timer-list |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
178 ;; to find out whether newsticker is running. Removed |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
179 ;; `newsticker-ticker-running-p'. |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
180 ;; * 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
|
181 ;; * Other minor changes. |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
182 |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
183 ;; 1.9 (2005-11-01) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
184 ;; * 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
|
185 ;; 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
|
186 ;; Nguyen. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
187 ;; * Changed auto-marking mechanism: Replaced variable |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
188 ;; `newsticker-auto-mark-filter' with new variable |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
189 ;; `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
|
190 ;; 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
|
191 ;; * Call `newsticker--ticker-text-setup' only after all pending |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
192 ;; downloads processes have finished. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
193 ;; * Improved handling of coding systems. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
194 ;; * Added magic autoload comments. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
195 ;; * Bugfixes: |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
196 ;; - `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
|
197 ;; headline, |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
198 ;; - update mode-line and menu-bar when necessary, |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
199 ;; - repaired `newsticker--imenu-goto', |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
200 ;; - other minor things. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
201 |
65468 | 202 ;; 1.8 (2005-08-26) |
203 ;; * Added commands `newsticker-show-extra' and `newsticker-hide-extra' | |
204 ;; to show and hide extra RSS elements, bound to "sx" and "hx" | |
205 ;; resp. Changed default value of `newsticker-show-all-rss-elements' | |
206 ;; to nil. | |
207 ;; * mode-line: Introduced special mode-line-format for newsticker. | |
208 ;; * Get feed logos only once every 24 h. | |
209 ;; * Default faces changed. | |
210 ;; * Minor fixes. | |
211 | |
212 ;; 1.7 (2005-06-25) | |
213 ;; * Tool-bar support: most important commands can be called from | |
214 ;; tool-bar buttons. | |
215 ;; * 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
|
216 ;; 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
|
217 ;; `xf'). |
65468 | 218 ;; * Enclosure support: enclosed items are shown (see |
219 ;; `newsticker-enclosure-face') and can be (automatically) downloaded | |
220 ;; (see below). For those of you who read "podcasts". | |
221 ;; * Added variable `newsticker-auto-mark-filter' for automatically | |
222 ;; marking items as immortal or old. | |
223 ;; * Added hook variable `newsticker-new-item-functions' for handling | |
224 ;; new items. Added sample functions `newsticker-download-images', | |
225 ;; and `newsticker-download-enclosures'. | |
226 ;; * Added hook variable `newsticker-select-item-hook' which is run | |
227 ;; after `newsticker-(next|previous)-(new-)?-item'. | |
228 ;; * Added hook variable `newsticker-select-feed-hook' which is run | |
229 ;; after `newsticker-(next|previous)-feed'. | |
230 ;; * Added hook variable `newsticker-buffer-change-hook' which is run | |
231 ;; after the contents or visibility of the newsticker buffer has | |
232 ;; changed, e.g. after `newsticker-buffer-update' or | |
233 ;; `newsticker-show-feed-desc'. | |
234 ;; * Added command `newsticker-handle-url' for interactively launching | |
235 ;; arbitrary programs for URLs, bound to `C-RET'. | |
236 ;; * URLs in extra elements are clickable. | |
237 ;; * Better support for w3, added command | |
238 ;; `newsticker-w3m-show-inline-images' for displaying all inline | |
239 ;; images. | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
240 ;; * Insert an artificial headline which notifies about failed |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
241 ;; retrievals. |
65468 | 242 ;; * Use pubDate element (RSS 2.0) instead of retrieval time when |
243 ;; available. | |
244 ;; * Customizable options grouped. | |
245 ;; * Bugfixes: `newsticker--imenu-create-index'; strip whitespace | |
246 ;; from links; apply coding-system to extra-elements; time-comparison | |
247 ;; 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
|
248 ;; * 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
|
249 ;; anonymous for sending patch. |
65468 | 250 ;; * Renamed invisible buffers ` *wget-newsticker-<feed>*' to |
251 ;; ` *newsticker-wget-<feed>*'. | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
252 ;; * 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
|
253 ;; 21.something. |
65468 | 254 |
255 ;; 1.6 * Support for (some) optional RSS elements: guid, dc:date. See | |
256 ;; `newsticker-show-all-rss-elements' `newsticker-extra-face'. | |
257 ;; * Better support for w3m -- `newsticker-default-face' is obsolete | |
258 ;; now, removed `newsticker-w3m-toggle-inline-image'. | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
259 ;; * Added `newsticker-desc-comp-max' -- comparison of item |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
260 ;; descriptions can take quite some time. |
65468 | 261 ;; * Added `newsticker--buffer-make-item-completely-visible' to |
262 ;; ensure that the current item is fully visible. | |
263 ;; * Allow for non-positive retrieval-interval, which make newsticker | |
264 ;; get news only once. | |
265 ;; * Use :set for customizable variables. | |
266 ;; * Added `newsticker-buffer-force-update', bound to key `U'. | |
267 ;; * Added concept of obsolete items, see | |
268 ;; `newsticker-keep-obsolete-items', `newsticker-obsolete-item-face', | |
269 ;; `newsticker-obsolete-item-max-age'. | |
270 ;; * Added `newsticker-add-url'. | |
271 ;; * OPML export. | |
272 ;; * Save pre-formatted titles => even better performance!! | |
273 ;; * `newsticker-*-new-item' wraps at beginning/end of buffer. | |
274 ;; * Always sort obsolete items to end of item list. | |
275 ;; * Bugfixes: | |
276 ;; - newsticker-hide-entry, | |
277 ;; - changes of feed-titles led to duplicate feed items, | |
278 ;; - faces for rendered HTML texts, | |
279 ;; - length of ticker-text (for "exotic"/multibyte texts), | |
280 ;; Thanks to Hiroshi Maruyama. | |
281 ;; - suppress items with empty title and description | |
282 ;; - newsticker-sort-method was ignored! | |
283 ;; - prevent call of fill-region on HTML-rendered descriptions. | |
284 | |
285 ;; 1.5 * Rewrote the visibility stuff. newsticker does not inherit | |
286 ;; outline anymore. Now you have complete freedom for | |
287 ;; `newsticker-*-format'. | |
288 ;; * Save pre-formatted descriptions => incredible performance boost!! | |
289 ;; * Introduced `newsticker-(start|stop)-ticker'. | |
290 ;; * Introduced statistics for heading-format and | |
291 ;; `newsticker-statistics-face'. | |
292 ;; * Introduced `newsticker-enable-logo-manipulations'. | |
293 ;; * Compare link of items (as well as title and desc). | |
294 ;; * Added `newsticker-start-hook' and `newsticker-stop-hook', thanks | |
295 ;; to mace. | |
296 ;; * Bugfixes -- thanks to Ryan Yeske, Jari Aalto, Bruce Ingalls. | |
297 ;; * Tested with Emacs 21.3.50, 21.3.1, 21.2, 21.1; XEmacs 21.4.15 | |
298 | |
299 ;; 1.4 * Enabled HTML rendering, added `newsticker-html-renderer' to | |
300 ;; choose a HTML rendering engine, thanks to Greg Scott for testing | |
301 ;; * New Outline handling using text properties instead of "**" | |
302 ;; prefixes. | |
303 ;; * Added possibility to mark single item as old (bound to key | |
304 ;; `o' (`newsticker-mark-item-at-point-as-read'). | |
305 ;; * Added possibility to mark single item as immortal (bound to key | |
306 ;; `i' (`newsticker-mark-item-at-point-as-immortal'). | |
307 ;; * Added possibility to display feed logos. | |
308 ;; * Added `newsticker-heading-format', `newsticker-item-format'. | |
309 ;; * Added `newsticker-date-format'. | |
310 ;; * Added `newsticker-justification'. | |
311 ;; * Added `newsticker-automatically-mark-visited-items-as-old'. | |
312 ;; * Added `newsticker-w3m-toggle-inline-image' which calls | |
313 ;; `w3m-toggle-inline-image' if `newsticker-html-renderer' is | |
314 ;; `w3m-region'. Exists for convenience only (bound to key | |
315 ;; `RET'). | |
316 | |
317 ;; 1.3 * Compare title AND desc to check whether item is old, except | |
318 ;; for feed desc | |
319 ;; * Mark as not-up-to-date only after new items have arrived. | |
320 ;; * Added XEmacs compatibility code, tested with XEmacs 21.4.13. | |
321 ;; * Tested with Emacs 21.3.50 and Emacs 21.2.something. | |
322 ;; * Bugfix: Apply coding-systems to feed title and description, | |
323 ;; thanks to OHASHI Akira | |
324 ;; * Bugfix: xml-parser-workaround did not work for japanese texts, | |
325 ;; thanks to OHASHI Akira | |
326 ;; * Kill wget-buffers unless newsticker-debug is not nil. | |
327 ;; * Bugfix: xml-parser-workaround for "DOCTYPE rdf:RDF" | |
328 | |
329 ;; 1.2 Peter S Galbraith <psg@debian.org> | |
330 ;; * Added `newsticker-url-list-defaults', splitting the URLs into | |
331 ;; a customizable selection list, and a user add-on list. | |
332 ;; * Minor checkdoc fixes. | |
333 | |
334 ;; 1.1 * Introduced optional feed-specific wget-arguments. | |
335 ;; * Keep order of feeds as given in `newsticker-url-list' in | |
336 ;; *newsticker* buffer. | |
337 ;; * Ignore unsupported coding systems. | |
338 | |
339 ;; 1.0 * Introduced feed-specific retrieval-timers. | |
340 ;; * Removed dependency on 'cl (cddddr). | |
341 ;; * Thanks to Kevin Rodgers and T.V. Raman for their help. | |
342 ;; * Use utf-8 for reading and writing cache data. | |
343 ;; * Reported to work with Emacs 21.3.50. | |
344 | |
345 ;; 0.99 * Minor tweaks. | |
346 ;; * Tested with Emacs 21.3.2 | |
347 | |
348 ;; 0.98 * Check exit status of wget processes. Keep cache data if | |
349 ;; something went wrong. Throw error when old wget-processes | |
350 ;; are hanging around. | |
351 ;; * Introduced newsticker-specific faces. | |
352 ;; * Added `newsticker-show-descriptions-of-new-items'. | |
353 ;; * Added `newsticker-hide-old-items-in-newsticker-buffer'. | |
354 ;; * Added `newsticker-(hide|show)-old-items'. | |
355 | |
356 ;; 0.97 * Minor tweaks. | |
357 | |
358 ;; 0.96 * Added caching. | |
359 ;; * newsticker-mode inherits outline-mode. | |
360 ;; * newsticker-mode supports imenu. | |
361 ;; * Easy buffer-navigation with newsticker-mode's keymap. | |
362 ;; * Some bugs fixed. | |
363 ;; * Thanks to Moritz Epple for documentation tips. | |
364 | |
365 ;; 0.95 * Added newsticker-mode -- Thanks to T.V. Raman. | |
366 ;; * Catch xml-parser errors -- Thanks to T.V. Raman. | |
367 ;; * Remove stupid newlines in titles (headlines) -- Thanks to | |
368 ;; Jeff Rancier. | |
369 | |
370 ;; 0.94 * Added clickerability and description for channel headings. | |
371 ;; * Made it work for (at least some) rss 0.9<something> feeds. | |
372 | |
373 ;; 0.93 * Added some more sites. | |
374 ;; * Do not flood the *Messages* buffer. | |
375 ;; * First attempt at handling coding systems. | |
376 | |
377 ;; 0.92 * Added `newsticker-wget-name'. | |
378 ;; * Try to display message only if minibuffer and echo area are | |
379 ;; not in use already. | |
380 ;; * Dirty workaround for newer versions of xml.el: Remove | |
381 ;; whitespace in rdf. | |
382 ;; * Tested with Emacs 21.3.2 and CVS-snapshot of 2003-06-21. | |
383 | |
384 ;; 0.91 * First bugfix: *newsticker* is read-only. | |
385 | |
386 ;; 0.9 * First release. | |
387 ;; * Tested with Emacs 21.3.2 and wget 1.8.2. | |
388 | |
389 ;; ====================================================================== | |
390 ;;; To Do: | |
391 | |
392 ;; * Image handling for XEmacs (create-image does not exist) | |
393 | |
394 ;; ====================================================================== | |
395 ;;; Code: | |
396 | |
397 (require 'derived) | |
398 (require 'xml) | |
399 | |
65490
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
400 ;; Silence warnings |
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
401 (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
|
402 (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
|
403 (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
|
404 |
65468 | 405 ;; ====================================================================== |
67593
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
406 ;;; Newsticker status |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
407 ;; ====================================================================== |
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 (defvar newsticker--retrieval-timer-list nil |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
410 "List of timers for news retrieval. |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
411 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
|
412 |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
413 (defvar newsticker--display-timer nil |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
414 "Timer for newsticker display.") |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
415 |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
416 ;;;###autoload |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
417 (defun newsticker-running-p () |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
418 "Check whether newsticker is running. |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
419 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
|
420 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
|
421 (> (length newsticker--retrieval-timer-list) 0)) |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
422 |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
423 ;;;###autoload |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
424 (defun newsticker-ticker-running-p () |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
425 "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
|
426 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
|
427 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
|
428 empty." |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
429 (timerp newsticker--display-timer)) |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
430 |
b42dfcb5e692
(newsticker--retrieval-timer-list, newsticker--display-timer)
Richard M. Stallman <rms@gnu.org>
parents:
66704
diff
changeset
|
431 ;; ====================================================================== |
65468 | 432 ;;; Customizables |
433 ;; ====================================================================== | |
434 (defgroup newsticker nil | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
435 "Aggregator for RSS and Atom feeds." |
65468 | 436 :group 'applications) |
437 | |
438 (defconst newsticker--raw-url-list-defaults | |
439 '(("CNET News.com" | |
440 "http://export.cnet.com/export/feeds/news/rss/1,11176,,00.xml") | |
441 ("Debian Security Advisories" | |
442 "http://www.debian.org/security/dsa.en.rdf") | |
443 ("Debian Security Advisories - Long format" | |
444 "http://www.debian.org/security/dsa-long.en.rdf") | |
445 ("Emacs Wiki" | |
446 "http://www.emacswiki.org/cgi-bin/wiki.pl?action=rss" | |
447 nil | |
448 3600) | |
449 ("Freshmeat.net" | |
450 "http://freshmeat.net/backend/fm.rdf") | |
451 ("Kuro5hin.org" | |
452 "http://www.kuro5hin.org/backend.rdf") | |
453 ("LWN (Linux Weekly News)" | |
454 "http://lwn.net/headlines/rss") | |
455 ("NewsForge" | |
456 "http://newsforge.com/index.rss") | |
457 ("NY Times: Technology" | |
458 "http://partners.userland.com/nytRss/technology.xml") | |
459 ("NY Times" | |
460 "http://partners.userland.com/nytRss/nytHomepage.xml") | |
461 ("Quote of the day" | |
462 "http://www.quotationspage.com/data/qotd.rss" | |
463 "07:00" | |
464 86400) | |
465 ("The Register" | |
466 "http://www.theregister.co.uk/tonys/slashdot.rdf") | |
467 ("slashdot" | |
468 "http://slashdot.org/index.rss" | |
469 nil | |
470 3600) ;/. will ban you if under 3600 seconds! | |
471 ("Wired News" | |
472 "http://www.wired.com/news_drop/netcenter/netcenter.rdf") | |
473 ("Heise News (german)" | |
474 "http://www.heise.de/newsticker/heise.rdf") | |
475 ("Tagesschau (german)" | |
476 "http://www.tagesschau.de/newsticker.rdf" | |
477 nil | |
478 1800) | |
479 ("Telepolis (german)" | |
480 "http://www.heise.de/tp/news.rdf")) | |
481 "Default URL list in raw form. | |
482 This list is fed into defcustom via `newsticker--splicer'.") | |
483 | |
484 (defun newsticker--splicer (item) | |
485 "Convert ITEM for splicing into `newsticker-url-list-defaults'." | |
486 (let ((result (list 'list :tag (nth 0 item) (list 'const (nth 0 item)))) | |
487 (element (cdr item))) | |
488 (while element | |
489 (setq result (append result (list (list 'const (car element))))) | |
490 (setq element (cdr element))) | |
491 result)) | |
492 | |
493 ;; ====================================================================== | |
494 ;;; Customization | |
495 ;; ====================================================================== | |
496 (defun newsticker--set-customvar (symbol value) | |
497 "Set newsticker-variable SYMBOL value to VALUE. | |
498 | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
499 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
|
500 the new value effective. Changing `newsticker-url-list', for example, |
65468 | 501 will re-start the retrieval-timers." |
502 (unless (condition-case nil | |
503 (eq (symbol-value symbol) value) | |
504 (error nil)) | |
505 (set symbol value) | |
506 (cond ((eq symbol 'newsticker-sort-method) | |
507 (when (fboundp 'newsticker--cache-sort) | |
508 (message "Applying new sort method...") | |
509 (newsticker--cache-sort) | |
510 (newsticker--buffer-set-uptodate nil) | |
511 (message "Applying new sort method...done"))) | |
512 ((memq symbol '(newsticker-url-list-defaults | |
513 newsticker-url-list | |
514 newsticker-retrieval-interval)) | |
515 (when (and (fboundp 'newsticker-running-p) | |
516 (newsticker-running-p)) | |
517 (message "Restarting newsticker") | |
518 (newsticker-stop) | |
519 (newsticker-start))) | |
520 ((eq symbol 'newsticker-display-interval) | |
521 (when (and (fboundp 'newsticker-running-p) | |
522 (newsticker-running-p)) | |
523 (message "Restarting ticker") | |
524 (newsticker-stop-ticker) | |
525 (newsticker-start-ticker) | |
526 (message ""))) | |
527 ((memq symbol '(newsticker-hide-old-items-in-echo-area | |
528 newsticker-hide-obsolete-items-in-echo-area | |
529 newsticker-hide-immortal-items-in-echo-area)) | |
530 (when (and (fboundp 'newsticker-running-p) | |
531 (newsticker-running-p)) | |
532 (message "Restarting newsticker") | |
533 (newsticker-stop-ticker) | |
534 (newsticker--ticker-text-setup) | |
535 (newsticker-start-ticker) | |
536 (message ""))) | |
537 ((memq symbol '(newsticker-hide-old-items-in-newsticker-buffer | |
538 newsticker-show-descriptions-of-new-items)) | |
539 (when (fboundp 'newsticker--buffer-set-uptodate) | |
540 (newsticker--buffer-set-uptodate nil))) | |
541 ((memq symbol '(newsticker-heading-format | |
542 newsticker-item-format | |
543 newsticker-desc-format | |
544 newsticker-date-format | |
545 newsticker-statistics-format | |
546 newsticker-justification | |
547 newsticker-use-full-width | |
548 newsticker-html-renderer | |
549 newsticker-feed-face | |
550 newsticker-new-item-face | |
551 newsticker-old-item-face | |
552 newsticker-immortal-item-face | |
553 newsticker-obsolete-item-face | |
554 newsticker-date-face | |
555 newsticker-statistics-face | |
556 ;;newsticker-default-face | |
557 )) | |
558 (when (fboundp 'newsticker--forget-preformatted) | |
559 (newsticker--forget-preformatted))) | |
560 (t | |
561 (error "Ooops %s" symbol))))) | |
562 | |
563 ;; customization group feed | |
564 (defgroup newsticker-feed nil | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
565 "Settings for news feeds." |
65468 | 566 :group 'newsticker) |
567 | |
568 (defcustom newsticker-url-list-defaults | |
569 '(("Emacs Wiki" | |
570 "http://www.emacswiki.org/cgi-bin/wiki.pl?action=rss" | |
571 nil | |
572 3600)) | |
573 "A customizable list of news feeds to select from. | |
574 These were mostly extracted from the Radio Community Server at | |
575 http://subhonker6.userland.com/rcsPublic/rssHotlist. | |
576 | |
577 You may add other entries in `newsticker-url-list'." | |
578 :type `(set ,@(mapcar `newsticker--splicer | |
579 newsticker--raw-url-list-defaults)) | |
580 :set 'newsticker--set-customvar | |
581 :group 'newsticker-feed) | |
582 | |
583 (defcustom newsticker-url-list nil | |
584 "The news feeds which you like to watch. | |
585 | |
586 This alist will be used in addition to selection made customizing | |
587 `newsticker-url-list-defaults'. | |
588 | |
589 This is an alist. Each element consists of two items: a LABEL and a URL, | |
590 optionally followed by a START-TIME, INTERVAL specifier and WGET-ARGUMENTS. | |
591 | |
592 The LABEL gives the name of the news feed. It can be an arbitrary string. | |
593 | |
594 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
|
595 RSS or Atom file. The file is retrieved by calling wget, or whatever you |
65468 | 596 specify as `newsticker-wget-name'. |
597 | |
598 The START-TIME can be either a string, or nil. If it is a string it | |
599 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
|
600 first time. (Examples: \"11:00pm\", \"23:00\".) If it is nil (or |
65468 | 601 unspecified), this feed will be retrieved immediately after calling |
602 `newsticker-start'. | |
603 | |
604 The INTERVAL specifies the time between retrievals for this feed. If it | |
605 is nil (or unspecified) the default interval value as set in | |
606 `newsticker-retrieval-interval' is used. | |
607 | |
608 \(newsticker.el calls `run-at-time'. The newsticker-parameters START-TIME | |
609 and INTERVAL correspond to the `run-at-time'-parameters TIME and REPEAT.) | |
610 | |
611 WGET-ARGUMENTS specifies arguments for wget (see `newsticker-wget-name') | |
612 which apply for this feed only, overriding the value of | |
613 `newsticker-wget-arguments'." | |
614 :type '(repeat (list :tag "News feed" | |
615 (string :tag "Label") | |
616 (string :tag "URI") | |
617 (choice :tag "Start" | |
618 (const :tag "Default" nil) | |
619 (string :tag "Fixed Time")) | |
620 (choice :tag "Interval" | |
621 (const :tag "Default" nil) | |
622 (const :tag "Hourly" 3600) | |
623 (const :tag "Daily" 86400) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
624 (const :tag "Weekly" 604800) |
65468 | 625 (integer :tag "Interval")) |
626 (choice :tag "Wget Arguments" | |
627 (const :tag "Default arguments" nil) | |
628 (repeat :tag "Special arguments" string)))) | |
629 :set 'newsticker--set-customvar | |
630 :group 'newsticker-feed) | |
631 | |
632 (defcustom newsticker-wget-name | |
633 "wget" | |
634 "Name of the program which is called to retrieve news from the web. | |
635 The canonical choice is wget but you may take any other program which is | |
636 able to return the contents of a news feed file on stdout." | |
637 :type 'string | |
638 :group 'newsticker-feed) | |
639 | |
640 (defcustom newsticker-wget-arguments | |
641 '("-q" "-O" "-") | |
642 "Arguments which are passed to wget. | |
643 There is probably no reason to change the default settings, unless you | |
644 are living behind a firewall." | |
645 :type '(repeat (string :tag "Argument")) | |
646 :group 'newsticker-feed) | |
647 | |
648 (defcustom newsticker-retrieval-interval | |
649 3600 | |
650 "Time interval for retrieving new news items (seconds). | |
651 If this value is not positive (i.e. less than or equal to 0) | |
652 items are retrieved only once! | |
653 Please note that some feeds, e.g. Slashdot, will ban you if you | |
654 make it less than 1800 seconds (30 minutes)!" | |
655 :type '(choice :tag "Interval" | |
656 (const :tag "No automatic retrieval" 0) | |
657 (const :tag "Hourly" 3600) | |
658 (const :tag "Daily" 86400) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
659 (const :tag "Weekly" 604800) |
65468 | 660 (integer :tag "Interval")) |
661 :set 'newsticker--set-customvar | |
662 :group 'newsticker-feed) | |
663 | |
664 (defcustom newsticker-desc-comp-max | |
665 100 | |
666 "Relevant length of headline descriptions. | |
667 This value gives the maximum number of characters which will be | |
668 taken into account when newsticker compares two headline | |
669 descriptions." | |
670 :type 'integer | |
671 :group 'newsticker-feed) | |
672 | |
673 ;; customization group behaviour | |
674 (defgroup newsticker-headline-processing nil | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
675 "Settings for the automatic processing of headlines." |
65468 | 676 :group 'newsticker) |
677 | |
678 (defcustom newsticker-automatically-mark-items-as-old | |
679 t | |
680 "Decides whether to automatically mark items as old. | |
681 If t a new item is considered as new only after its first retrieval. As | |
682 soon as it is retrieved a second time, it becomes old. If not t all | |
683 items stay new until you mark them as old. This is done in the | |
684 *newsticker* buffer." | |
685 :type 'boolean | |
686 :group 'newsticker-headline-processing) | |
687 | |
688 (defcustom newsticker-automatically-mark-visited-items-as-old | |
689 t | |
690 "Decides whether to automatically mark visited items as old. | |
691 If t an item is marked as old as soon as the associated link is | |
692 visited, i.e. after pressing RET or mouse2 on the item's | |
693 headline." | |
694 | |
695 :type 'boolean | |
696 :group 'newsticker-headline-processing) | |
697 | |
698 (defcustom newsticker-keep-obsolete-items | |
699 t | |
700 "Decides whether to keep unread items which have been removed from feed. | |
701 If t a new item, which has been removed from the feed, is kept in | |
702 the cache until it is marked as read." | |
703 :type 'boolean | |
704 :group 'newsticker-headline-processing) | |
705 | |
706 (defcustom newsticker-obsolete-item-max-age | |
707 (* 60 60 24) | |
708 "Maximal age of obsolete items, in seconds. | |
709 Obsolete items which are older than this value will be silently | |
710 deleted at the next retrieval." | |
711 :type 'integer | |
712 :group 'newsticker-headline-processing) | |
713 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
714 (defcustom newsticker-auto-mark-filter-list |
65468 | 715 nil |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
716 "A list of filters for automatically marking headlines. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
717 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
718 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
|
719 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
|
720 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
|
721 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
|
722 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
|
723 '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
|
724 string. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
725 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
726 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
|
727 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
|
728 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
|
729 if REGEXP matches the headline's TITLE-OR-DESCRIPTION. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
730 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
731 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
|
732 \((slashdot ('old 'title \"^Forget me!$\") ('immortal 'title \"Read me\") |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
733 \('immortal 'all \"important\")))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
734 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
735 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
|
736 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
|
737 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
|
738 contain the string \"important\" in their title or their |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
739 description are marked as immortal." |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
740 :type '(repeat (list :tag "Auto mark filter" |
65468 | 741 (string :tag "Feed name") |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
742 (repeat |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
743 (list :tag "Filter element" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
744 (choice |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
745 :tag "Auto-assigned age" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
746 (const :tag "Old" old) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
747 (const :tag "Immortal" immortal)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
748 (choice |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
749 :tag "Title/Description" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
750 (const :tag "Title" title) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
751 (const :tag "Description" description) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
752 (const :tag "All" all)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
753 (string :tag "Regexp"))))) |
65468 | 754 :group 'newsticker-headline-processing) |
755 | |
756 ;; customization group layout | |
757 (defgroup newsticker-layout nil | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
758 "Settings for layout of the feed reader." |
65468 | 759 :group 'newsticker) |
760 | |
761 (defcustom newsticker-sort-method | |
762 'sort-by-original-order | |
763 "Sort method for news items. | |
764 The following sort methods are available: | |
765 * `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
|
766 appear in the headline file (please note that for immortal items, |
65468 | 767 which have been removed from the news feed, there is no original |
768 order), | |
769 * `sort-by-time' looks at the time at which an item has been seen | |
770 the first time. The most recent item is put at top, | |
771 * `sort-by-title' will put the items in an alphabetical order." | |
772 :type '(choice | |
773 (const :tag "Keep original order" sort-by-original-order) | |
774 (const :tag "Sort by time" sort-by-time) | |
775 (const :tag "Sort by title" sort-by-title)) | |
776 :set 'newsticker--set-customvar | |
777 :group 'newsticker-layout) | |
778 | |
779 (defcustom newsticker-hide-old-items-in-newsticker-buffer | |
780 nil | |
781 "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
|
782 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
|
783 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
|
784 well as new items will be visible." |
65468 | 785 :type 'boolean |
786 :set 'newsticker--set-customvar | |
787 :group 'newsticker-layout) | |
788 | |
789 (defcustom newsticker-show-descriptions-of-new-items | |
790 t | |
791 "Whether to automatically show descriptions of new items in *newsticker*. | |
792 If set to t old items will be folded and new items will be | |
793 unfolded. Otherwise old as well as new items will be folded." | |
794 :type 'boolean | |
795 :set 'newsticker--set-customvar | |
796 :group 'newsticker-layout) | |
797 | |
798 (defcustom newsticker-heading-format | |
799 "%l | |
800 %t %d %s" | |
801 "Format string for feed headings. | |
802 The following printf-like specifiers can be used: | |
803 %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
|
804 %l The logo (image) of the feed. Most news feeds provide a small |
65468 | 805 image as logo. Newsticker can display them, if Emacs can -- |
806 see `image-types' for a list of supported image types. | |
807 %L The logo (image) of the feed. If the logo is not available | |
808 the title of the feed is used. | |
809 %s The statistical data of the feed. See `newsticker-statistics-format'. | |
810 %t The title of the feed, i.e. its name." | |
811 :type 'string | |
812 :set 'newsticker--set-customvar | |
813 :group 'newsticker-layout) | |
814 | |
815 (defcustom newsticker-item-format | |
816 "%t %d" | |
817 "Format string for news item headlines. | |
818 The following printf-like specifiers can be used: | |
819 %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
|
820 %l The logo (image) of the feed. Most news feeds provide a small |
65468 | 821 image as logo. Newsticker can display them, if Emacs can -- |
822 see `image-types' for a list of supported image types. | |
823 %L The logo (image) of the feed. If the logo is not available | |
824 the title of the feed is used. | |
825 %t The title of the item." | |
826 :type 'string | |
827 :set 'newsticker--set-customvar | |
828 :group 'newsticker-layout) | |
829 | |
830 (defcustom newsticker-desc-format | |
831 "%d %c" | |
832 "Format string for news descriptions (contents). | |
833 The following printf-like specifiers can be used: | |
834 %c The contents (description) of the item. | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
835 %d The date the item was (first) retrieved. See |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
836 `newsticker-date-format'." |
65468 | 837 :type 'string |
838 :set 'newsticker--set-customvar | |
839 :group 'newsticker-layout) | |
840 | |
841 (defcustom newsticker-date-format | |
842 "(%A, %H:%M)" | |
843 "Format for the date part in item and feed lines. | |
844 See `format-time-string' for a list of valid specifiers." | |
845 :type 'string | |
846 :set 'newsticker--set-customvar | |
847 :group 'newsticker-layout) | |
848 | |
849 (defcustom newsticker-statistics-format | |
850 "[%n + %i + %o + %O = %a]" | |
851 "Format for the statistics part in feed lines. | |
852 The following printf-like specifiers can be used: | |
853 %a The number of all items in the feed. | |
854 %i The number of immortal items in the feed. | |
855 %n The number of new items in the feed. | |
856 %o The number of old items in the feed. | |
857 %O The number of obsolete items in the feed." | |
858 :type 'string | |
859 :set 'newsticker--set-customvar | |
860 :group 'newsticker-layout) | |
861 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
862 (defcustom newsticker-show-all-news-elements |
65468 | 863 nil |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
864 "Show all news elements." |
65468 | 865 :type 'boolean |
866 ;;:set 'newsticker--set-customvar | |
867 :group 'newsticker-layout) | |
868 | |
869 ;; image related things | |
870 (defcustom newsticker-enable-logo-manipulations | |
871 t | |
872 "If non-nil newsticker manipulates logo images. | |
873 This enables the following image properties: heuristic mask for all | |
874 logos, and laplace-conversion for images without new items." | |
875 :type 'boolean | |
876 :group 'newsticker-layout) | |
877 | |
878 | |
879 ;; rendering | |
880 (defcustom newsticker-justification | |
881 'left | |
882 "How to fill item descriptions. | |
883 If non-nil newsticker calls `fill-region' to wrap long lines in | |
884 item descriptions. However, if an item description contains HTML | |
885 text and `newsticker-html-renderer' is non-nil, filling is not | |
886 done." | |
887 :type '(choice :tag "Justification" | |
888 (const :tag "No filling" nil) | |
889 (const :tag "Left" left) | |
890 (const :tag "Right" right) | |
891 (const :tag "Center" center) | |
892 (const :tag "Full" full)) | |
893 :set 'newsticker--set-customvar | |
894 :group 'newsticker-layout) | |
895 | |
896 (defcustom newsticker-use-full-width | |
897 t | |
898 "Decides whether to use the full window width when filling. | |
899 If non-nil newsticker sets `fill-column' so that the whole | |
900 window is used when filling. See also `newsticker-justification'." | |
901 :type 'boolean | |
902 :set 'newsticker--set-customvar | |
903 :group 'newsticker-layout) | |
904 | |
905 (defcustom newsticker-html-renderer | |
906 nil | |
907 "Function for rendering HTML contents. | |
908 If non-nil, newsticker.el will call this function whenever it finds | |
909 HTML-like tags in item descriptions. Possible functions are, for | |
910 example, `w3m-region', `w3-region', and (if you have htmlr.el installed) | |
911 `newsticker-htmlr-render'. | |
912 | |
913 In order to make sure that the HTML renderer is loaded when you | |
914 run newsticker, you should add one of the following statements to | |
915 your .emacs. If you use w3m, | |
916 | |
917 (autoload 'w3m-region \"w3m\" | |
918 \"Render region in current buffer and replace with result.\" t) | |
919 | |
920 or, if you use w3, | |
921 | |
922 (require 'w3-auto) | |
923 | |
924 or, if you use htmlr | |
925 | |
926 (require 'htmlr)" | |
927 :type '(choice :tag "Function" | |
928 (const :tag "None" nil) | |
929 (const :tag "w3" w3-region) | |
930 (const :tag "w3m" w3m-region) | |
931 (const :tag "htmlr" newsticker-htmlr-render)) | |
932 :set 'newsticker--set-customvar | |
933 :group 'newsticker-layout) | |
934 | |
935 | |
936 ;; faces | |
937 (defgroup newsticker-faces nil | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
938 "Settings for the faces of the feed reader." |
65468 | 939 :group 'newsticker-layout) |
940 | |
941 (defface newsticker-feed-face | |
942 '((((class color) (background dark)) | |
943 (:family "helvetica" :bold t :height 1.2 :foreground "misty rose")) | |
944 (((class color) (background light)) | |
945 (:family "helvetica" :bold t :height 1.2 :foreground "black"))) | |
946 "Face for news feeds." | |
947 :group 'newsticker-faces) | |
948 | |
949 (defface newsticker-new-item-face | |
950 '((((class color) (background dark)) | |
951 (:family "helvetica" :bold t)) | |
952 (((class color) (background light)) | |
953 (:family "helvetica" :bold t))) | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
954 "Face for new news items." |
65468 | 955 :group 'newsticker-faces) |
956 | |
957 (defface newsticker-old-item-face | |
958 '((((class color) (background dark)) | |
959 (:family "helvetica" :bold t :foreground "orange3")) | |
960 (((class color) (background light)) | |
961 (:family "helvetica" :bold t :foreground "red4"))) | |
962 "Face for old news items." | |
963 :group 'newsticker-faces) | |
964 | |
965 (defface newsticker-immortal-item-face | |
966 '((((class color) (background dark)) | |
967 (:family "helvetica" :bold t :italic t :foreground "orange")) | |
968 (((class color) (background light)) | |
969 (:family "helvetica" :bold t :italic t :foreground "blue"))) | |
970 "Face for immortal news items." | |
971 :group 'newsticker-faces) | |
972 | |
973 (defface newsticker-obsolete-item-face | |
974 '((((class color) (background dark)) | |
975 (:family "helvetica" :bold t :strike-through t)) | |
976 (((class color) (background light)) | |
977 (:family "helvetica" :bold t :strike-through t))) | |
978 "Face for old news items." | |
979 :group 'newsticker-faces) | |
980 | |
981 (defface newsticker-date-face | |
982 '((((class color) (background dark)) | |
983 (:family "helvetica" :italic t :height 0.8)) | |
984 (((class color) (background light)) | |
985 (:family "helvetica" :italic t :height 0.8))) | |
986 "Face for newsticker dates." | |
987 :group 'newsticker-faces) | |
988 | |
989 (defface newsticker-statistics-face | |
990 '((((class color) (background dark)) | |
991 (:family "helvetica" :italic t :height 0.8)) | |
992 (((class color) (background light)) | |
993 (:family "helvetica" :italic t :height 0.8))) | |
994 "Face for newsticker dates." | |
995 :group 'newsticker-faces) | |
996 | |
997 (defface newsticker-enclosure-face | |
998 '((((class color) (background dark)) | |
999 (:bold t :background "orange")) | |
1000 (((class color) (background light)) | |
1001 (:bold t :background "orange"))) | |
1002 "Face for enclosed elements." | |
1003 :group 'newsticker-faces) | |
1004 | |
1005 (defface newsticker-extra-face | |
1006 '((((class color) (background dark)) | |
1007 (:italic t :foreground "gray50" :height 0.8)) | |
1008 (((class color) (background light)) | |
1009 (:italic t :foreground "gray50" :height 0.8))) | |
1010 "Face for newsticker dates." | |
1011 :group 'newsticker-faces) | |
1012 | |
1013 ;; (defface newsticker-default-face | |
1014 ;; '((((class color) (background dark)) | |
1015 ;; (:inherit default)) | |
1016 ;; (((class color) (background light)) | |
1017 ;; (:inherit default))) | |
1018 ;; "Face for the description of news items." | |
1019 ;; ;;:set 'newsticker--set-customvar | |
1020 ;; :group 'newsticker-faces) | |
1021 | |
1022 | |
1023 ;; customization group ticker | |
1024 (defgroup newsticker-ticker nil | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
1025 "Settings for the headline ticker." |
65468 | 1026 :group 'newsticker) |
1027 | |
1028 (defcustom newsticker-display-interval | |
1029 0.3 | |
1030 "Time interval for displaying news items in the echo area (seconds). | |
1031 If equal or less than 0 no messages are shown in the echo area. For | |
1032 smooth display (see `newsticker-scroll-smoothly') a value of 0.3 seems | |
1033 reasonable. For non-smooth display a value of 10 is a good starting | |
1034 point." | |
1035 :type 'number | |
1036 :set 'newsticker--set-customvar | |
1037 :group 'newsticker-ticker) | |
1038 | |
1039 (defcustom newsticker-scroll-smoothly | |
1040 t | |
1041 "Decides whether to flash or scroll news items. | |
1042 If t the news headlines are scrolled (more-or-less) smoothly in the echo | |
1043 area. If nil one headline after another is displayed in the echo area. | |
1044 The variable `newsticker-display-interval' determines how fast this | |
1045 display moves/changes and whether headlines are shown in the echo area | |
1046 at all. If you change `newsticker-scroll-smoothly' you should also change | |
1047 `newsticker-display-interval'." | |
1048 :type 'boolean | |
1049 :group 'newsticker-ticker) | |
1050 | |
1051 (defcustom newsticker-hide-immortal-items-in-echo-area | |
1052 t | |
1053 "Decides whether to show immortal/non-expiring news items in the ticker. | |
1054 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
|
1055 `newsticker-hide-old-items-in-echo-area'." |
65468 | 1056 :type 'boolean |
1057 :set 'newsticker--set-customvar | |
1058 :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
|
1059 |
65468 | 1060 (defcustom newsticker-hide-old-items-in-echo-area |
1061 t | |
1062 "Decides whether to show only the newest news items in the ticker. | |
1063 If t the echo area will show only new items, i.e. only items which have | |
1064 been added between the last two retrievals." | |
1065 :type 'boolean | |
1066 :set 'newsticker--set-customvar | |
1067 :group 'newsticker-ticker) | |
1068 | |
1069 (defcustom newsticker-hide-obsolete-items-in-echo-area | |
1070 t | |
1071 "Decides whether to show obsolete items items in the ticker. | |
1072 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
|
1073 `newsticker-hide-old-items-in-echo-area'." |
65468 | 1074 :type 'boolean |
1075 :set 'newsticker--set-customvar | |
1076 :group 'newsticker-ticker) | |
1077 | |
1078 (defgroup newsticker-hooks nil | |
1079 "Settings for newsticker hooks." | |
1080 :group 'newsticker) | |
1081 | |
1082 (defcustom newsticker-start-hook | |
1083 nil | |
1084 "Hook run when starting newsticker. | |
1085 This hook is run at the very end of `newsticker-start'." | |
1086 :options '(newsticker-start-ticker) | |
1087 :type 'hook | |
1088 :group 'newsticker-hooks) | |
1089 | |
1090 (defcustom newsticker-stop-hook | |
1091 nil | |
1092 "Hook run when stopping newsticker. | |
1093 This hook is run at the very end of `newsticker-stop'." | |
1094 :options nil | |
1095 :type 'hook | |
1096 :group 'newsticker-hooks) | |
1097 | |
1098 (defcustom newsticker-new-item-functions | |
1099 nil | |
1100 "List of functions run after a new headline has been retrieved. | |
1101 Each function is called with the following three arguments: | |
1102 FEED the name of the corresponding news feed, | |
1103 TITLE the title of the headline, | |
1104 DESC the decoded description of the headline. | |
1105 | |
1106 See `newsticker-download-images', and | |
1107 `newsticker-download-enclosures' for sample functions. | |
1108 | |
1109 Please note that these functions are called only once for a | |
1110 headline after it has been retrieved for the first time." | |
1111 :type 'hook | |
1112 :options '(newsticker-download-images | |
1113 newsticker-download-enclosures) | |
1114 :group 'newsticker-hooks) | |
1115 | |
1116 (defcustom newsticker-select-item-hook | |
1117 'newsticker--buffer-make-item-completely-visible | |
1118 "List of functions run after a headline has been selected. | |
1119 Each function is called after one of `newsticker-next-item', | |
1120 `newsticker-next-new-item', `newsticker-previous-item', | |
1121 `newsticker-previous-new-item' has been called. | |
1122 | |
1123 The default value 'newsticker--buffer-make-item-completely-visible | |
1124 assures that the current item is always completely visible." | |
1125 :type 'hook | |
1126 :options '(newsticker--buffer-make-item-completely-visible) | |
1127 :group 'newsticker-hooks) | |
1128 | |
1129 (defcustom newsticker-select-feed-hook | |
1130 'newsticker--buffer-make-item-completely-visible | |
1131 "List of functions run after a feed has been selected. | |
1132 Each function is called after one of `newsticker-next-feed', and | |
1133 `newsticker-previous-feed' has been called. | |
1134 | |
1135 The default value 'newsticker--buffer-make-item-completely-visible | |
1136 assures that the current feed is completely visible." | |
1137 :type 'hook | |
1138 :options '(newsticker--buffer-make-item-completely-visible) | |
1139 :group 'newsticker-hooks) | |
1140 | |
1141 (defcustom newsticker-buffer-change-hook | |
1142 'newsticker-w3m-show-inline-images | |
1143 "List of functions run after the newsticker buffer has been updated. | |
1144 Each function is called after `newsticker-buffer-update' has been called. | |
1145 | |
1146 The default value '`newsticker-w3m-show-inline-images' loads inline | |
1147 images." | |
1148 :type 'hook | |
1149 :group 'newsticker-hooks) | |
1150 | |
1151 (defcustom newsticker-narrow-hook | |
1152 'newsticker-w3m-show-inline-images | |
1153 "List of functions run after narrowing in newsticker buffer has changed. | |
1154 Each function is called after | |
1155 `newsticker-toggle-auto-narrow-to-feed' or | |
1156 `newsticker-toggle-auto-narrow-to-item' has been called. | |
1157 | |
1158 The default value '`newsticker-w3m-show-inline-images' loads inline | |
1159 images." | |
1160 :type 'hook | |
1161 :group 'newsticker-hooks) | |
1162 | |
1163 (defgroup newsticker-miscellaneous nil | |
1164 "Miscellaneous newsticker settings." | |
1165 :group 'newsticker) | |
1166 | |
1167 (defcustom newsticker-cache-filename | |
1168 "~/.newsticker-cache" | |
1169 "Name of the newsticker cache file." | |
1170 :type 'string | |
1171 :group 'newsticker-miscellaneous) | |
1172 | |
1173 (defcustom newsticker-imagecache-dirname | |
1174 "~/.newsticker-images" | |
1175 "Name of the directory where newsticker stores cached images." | |
1176 :type 'string | |
1177 :group 'newsticker-miscellaneous) | |
1178 | |
1179 ;; debugging | |
1180 (defcustom newsticker-debug | |
1181 nil | |
1182 "Enables some features needed for debugging newsticker.el. | |
1183 | |
1184 If set to t newsticker.el will print lots of debugging messages, and the | |
1185 buffers *newsticker-wget-<feed>* will not be closed." | |
1186 :type 'boolean | |
1187 ;;:set 'newsticker--set-customvar | |
1188 :group 'newsticker-miscellaneous) | |
1189 | |
1190 ;; ====================================================================== | |
1191 ;;; Compatibility section, XEmacs, Emacs | |
1192 ;; ====================================================================== | |
1193 (unless (fboundp 'time-add) | |
1194 (require 'time-date);;FIXME | |
1195 (defun time-add (t1 t2) | |
1196 (seconds-to-time (+ (time-to-seconds t1) (time-to-seconds t2))))) | |
1197 | |
1198 (unless (fboundp 'match-string-no-properties) | |
1199 (defalias 'match-string-no-properties 'match-string)) | |
1200 | |
1201 (unless (fboundp 'replace-regexp-in-string) | |
1202 (defun replace-regexp-in-string (re rp st) | |
1203 (save-match-data ;; apparently XEmacs needs save-match-data | |
1204 (replace-in-string st re rp)))) | |
1205 | |
1206 ;; copied from subr.el | |
1207 (unless (fboundp 'add-to-invisibility-spec) | |
1208 (defun add-to-invisibility-spec (arg) | |
1209 "Add elements to `buffer-invisibility-spec'. | |
1210 See documentation for `buffer-invisibility-spec' for the kind of elements | |
1211 that can be added." | |
1212 (if (eq buffer-invisibility-spec t) | |
1213 (setq buffer-invisibility-spec (list t))) | |
1214 (setq buffer-invisibility-spec | |
1215 (cons arg buffer-invisibility-spec)))) | |
1216 | |
1217 ;; copied from subr.el | |
1218 (unless (fboundp 'remove-from-invisibility-spec) | |
1219 (defun remove-from-invisibility-spec (arg) | |
1220 "Remove elements from `buffer-invisibility-spec'." | |
1221 (if (consp buffer-invisibility-spec) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
1222 (setq buffer-invisibility-spec |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
1223 (delete arg buffer-invisibility-spec))))) |
65468 | 1224 |
1225 ;; ====================================================================== | |
1226 ;;; Internal variables | |
1227 ;; ====================================================================== | |
1228 (defvar newsticker--item-list nil | |
1229 "List of newsticker items.") | |
1230 (defvar newsticker--item-position 0 | |
1231 "Actual position in list of newsticker items.") | |
1232 (defvar newsticker--prev-message "There was no previous message yet!" | |
1233 "Last message that the newsticker displayed.") | |
1234 (defvar newsticker--scrollable-text "" | |
1235 "The text which is scrolled smoothly in the echo area.") | |
1236 (defvar newsticker--buffer-uptodate-p nil | |
1237 "Tells whether the newsticker buffer is up to date.") | |
1238 (defvar newsticker--latest-update-time (current-time) | |
1239 "The time at which the latest news arrived.") | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
1240 (defvar newsticker--process-ids nil |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
1241 "List of PIDs of active newsticker processes.") |
65468 | 1242 |
1243 (defvar newsticker--cache nil "Cached newsticker data. | |
1244 This is a list of the form | |
1245 | |
1246 ((label1 | |
1247 (title description link time age index preformatted-contents | |
1248 preformatted-title) | |
1249 ...) | |
1250 (label2 | |
1251 (title description link time age index preformatted-contents | |
1252 preformatted-title) | |
1253 ...) | |
1254 ...) | |
1255 | |
1256 where LABEL is a symbol. TITLE, DESCRIPTION, and LINK are | |
1257 strings. TIME is a time value as returned by `current-time'. | |
1258 AGE is a symbol: 'new, 'old, 'immortal, and 'obsolete denote | |
1259 ordinary news items, whereas 'feed denotes an item which is not a | |
1260 headline but describes the feed itself. INDEX denotes the | |
1261 original position of the item -- used for restoring the original | |
1262 order. PREFORMATTED-CONTENTS and PREFORMATTED-TITLE hold the | |
1263 formatted contents of the item's description and title. This | |
1264 speeds things up if HTML rendering is used, which is rather | |
1265 slow.") | |
1266 | |
1267 (defvar newsticker--auto-narrow-to-feed nil | |
1268 "Automatically narrow to current news feed. | |
1269 If non-nil only the items of the current news feed are visible.") | |
1270 | |
1271 (defvar newsticker--auto-narrow-to-item nil | |
1272 "Automatically narrow to current news item. | |
1273 If non-nil only the current headline is visible.") | |
1274 | |
1275 (defconst newsticker--error-headline | |
1276 "[COULD NOT DOWNLOAD HEADLINES!]" | |
1277 "Title of error headline which will be inserted if news retrieval fails.") | |
1278 | |
1279 ;; ====================================================================== | |
1280 ;;; Toolbar | |
1281 ;; ====================================================================== | |
1282 (defconst newsticker--next-item-image | |
1283 (if (fboundp 'create-image) | |
1284 (create-image "/* XPM */ | |
1285 static char * next_xpm[] = { | |
1286 \"24 24 42 1\", | |
1287 \" c None\", | |
1288 \". c #000000\", | |
1289 \"+ c #7EB6DE\", | |
1290 \"@ c #82BBE2\", | |
1291 \"# c #85BEE4\", | |
1292 \"$ c #88C1E7\", | |
1293 \"% c #8AC3E8\", | |
1294 \"& c #87C1E6\", | |
1295 \"* c #8AC4E9\", | |
1296 \"= c #8CC6EA\", | |
1297 \"- c #8CC6EB\", | |
1298 \"; c #88C2E7\", | |
1299 \"> c #8BC5E9\", | |
1300 \", c #8DC7EB\", | |
1301 \"' c #87C0E6\", | |
1302 \") c #8AC4E8\", | |
1303 \"! c #8BC5EA\", | |
1304 \"~ c #8BC4E9\", | |
1305 \"{ c #88C1E6\", | |
1306 \"] c #89C3E8\", | |
1307 \"^ c #86BFE5\", | |
1308 \"/ c #83BBE2\", | |
1309 \"( c #82BBE1\", | |
1310 \"_ c #86C0E5\", | |
1311 \": c #87C0E5\", | |
1312 \"< c #83BCE2\", | |
1313 \"[ c #81B9E0\", | |
1314 \"} c #81BAE1\", | |
1315 \"| c #78B0D9\", | |
1316 \"1 c #7BB3DB\", | |
1317 \"2 c #7DB5DD\", | |
1318 \"3 c #7DB6DD\", | |
1319 \"4 c #72A9D4\", | |
1320 \"5 c #75ACD6\", | |
1321 \"6 c #76AED7\", | |
1322 \"7 c #77AFD8\", | |
1323 \"8 c #6BA1CD\", | |
1324 \"9 c #6EA4CF\", | |
1325 \"0 c #6FA6D1\", | |
1326 \"a c #6298C6\", | |
1327 \"b c #659BC8\", | |
1328 \"c c #5C91C0\", | |
1329 \" \", | |
1330 \" \", | |
1331 \" . \", | |
1332 \" .. \", | |
1333 \" .+. \", | |
1334 \" .@#. \", | |
1335 \" .#$%. \", | |
1336 \" .&*=-. \", | |
1337 \" .;>,,,. \", | |
1338 \" .;>,,,=. \", | |
1339 \" .')!==~;. \", | |
1340 \" .#{]*%;^/. \", | |
1341 \" .(#_':#<. \", | |
1342 \" .+[@</}. \", | |
1343 \" .|1232. \", | |
1344 \" .4567. \", | |
1345 \" .890. \", | |
1346 \" .ab. \", | |
1347 \" .c. \", | |
1348 \" .. \", | |
1349 \" . \", | |
1350 \" \", | |
1351 \" \", | |
1352 \" \"}; | |
1353 " | |
1354 'xpm t) | |
1355 "Image for the next item button.")) | |
1356 | |
1357 (defconst newsticker--previous-item-image | |
1358 (if (fboundp 'create-image) | |
1359 (create-image "/* XPM */ | |
1360 static char * previous_xpm[] = { | |
1361 \"24 24 39 1\", | |
1362 \" c None\", | |
1363 \". c #000000\", | |
1364 \"+ c #7BB3DB\", | |
1365 \"@ c #83BCE2\", | |
1366 \"# c #7FB8DF\", | |
1367 \"$ c #89C2E7\", | |
1368 \"% c #86BFE5\", | |
1369 \"& c #83BBE2\", | |
1370 \"* c #8CC6EA\", | |
1371 \"= c #8BC4E9\", | |
1372 \"- c #88C2E7\", | |
1373 \"; c #85BEE4\", | |
1374 \"> c #8DC7EB\", | |
1375 \", c #89C3E8\", | |
1376 \"' c #8AC4E8\", | |
1377 \") c #8BC5EA\", | |
1378 \"! c #88C1E6\", | |
1379 \"~ c #8AC4E9\", | |
1380 \"{ c #8AC3E8\", | |
1381 \"] c #86C0E5\", | |
1382 \"^ c #87C0E6\", | |
1383 \"/ c #87C0E5\", | |
1384 \"( c #82BBE2\", | |
1385 \"_ c #81BAE1\", | |
1386 \": c #7FB7DF\", | |
1387 \"< c #7DB6DD\", | |
1388 \"[ c #7DB5DD\", | |
1389 \"} c #7CB4DC\", | |
1390 \"| c #79B1DA\", | |
1391 \"1 c #76ADD7\", | |
1392 \"2 c #77AFD8\", | |
1393 \"3 c #73AAD4\", | |
1394 \"4 c #70A7D1\", | |
1395 \"5 c #6EA5D0\", | |
1396 \"6 c #6CA2CE\", | |
1397 \"7 c #689ECB\", | |
1398 \"8 c #6399C7\", | |
1399 \"9 c #6095C4\", | |
1400 \"0 c #5C90C0\", | |
1401 \" \", | |
1402 \" \", | |
1403 \" . \", | |
1404 \" .. \", | |
1405 \" .+. \", | |
1406 \" .@#. \", | |
1407 \" .$%&. \", | |
1408 \" .*=-;. \", | |
1409 \" .>>*,%. \", | |
1410 \" .>>>*,%. \", | |
1411 \" .')**=-;. \", | |
1412 \" .;!,~{-%&. \", | |
1413 \" .;]^/;@#. \", | |
1414 \" .(@&_:+. \", | |
1415 \" .<[}|1. \", | |
1416 \" .2134. \", | |
1417 \" .567. \", | |
1418 \" .89. \", | |
1419 \" .0. \", | |
1420 \" .. \", | |
1421 \" . \", | |
1422 \" \", | |
1423 \" \", | |
1424 \" \"}; | |
1425 " | |
1426 'xpm t) | |
1427 "Image for the previous item button.")) | |
1428 | |
1429 (defconst newsticker--previous-feed-image | |
1430 (if (fboundp 'create-image) | |
1431 (create-image "/* XPM */ | |
1432 static char * prev_feed_xpm[] = { | |
1433 \"24 24 52 1\", | |
1434 \" c None\", | |
1435 \". c #000000\", | |
1436 \"+ c #70A7D2\", | |
1437 \"@ c #75ADD6\", | |
1438 \"# c #71A8D3\", | |
1439 \"$ c #79B1DA\", | |
1440 \"% c #7BB3DB\", | |
1441 \"& c #7DB5DD\", | |
1442 \"* c #83BBE2\", | |
1443 \"= c #7EB6DE\", | |
1444 \"- c #78B0D9\", | |
1445 \"; c #7FB7DE\", | |
1446 \"> c #88C2E7\", | |
1447 \", c #85BEE4\", | |
1448 \"' c #80B9E0\", | |
1449 \") c #80B8DF\", | |
1450 \"! c #8CC6EA\", | |
1451 \"~ c #89C3E8\", | |
1452 \"{ c #86BFE5\", | |
1453 \"] c #81BAE1\", | |
1454 \"^ c #7CB4DC\", | |
1455 \"/ c #7FB8DF\", | |
1456 \"( c #8DC7EB\", | |
1457 \"_ c #7BB3DC\", | |
1458 \": c #7EB7DE\", | |
1459 \"< c #8BC4E9\", | |
1460 \"[ c #8AC4E9\", | |
1461 \"} c #8AC3E8\", | |
1462 \"| c #87C0E6\", | |
1463 \"1 c #87C0E5\", | |
1464 \"2 c #83BCE2\", | |
1465 \"3 c #75ACD6\", | |
1466 \"4 c #7FB7DF\", | |
1467 \"5 c #77AED8\", | |
1468 \"6 c #71A8D2\", | |
1469 \"7 c #70A7D1\", | |
1470 \"8 c #76ADD7\", | |
1471 \"9 c #6CA2CE\", | |
1472 \"0 c #699FCC\", | |
1473 \"a c #73AAD4\", | |
1474 \"b c #6BA1CD\", | |
1475 \"c c #669CC9\", | |
1476 \"d c #6298C5\", | |
1477 \"e c #689ECB\", | |
1478 \"f c #6499C7\", | |
1479 \"g c #6095C3\", | |
1480 \"h c #5C91C0\", | |
1481 \"i c #5E93C2\", | |
1482 \"j c #5B90C0\", | |
1483 \"k c #588CBC\", | |
1484 \"l c #578CBC\", | |
1485 \"m c #5589BA\", | |
1486 \" \", | |
1487 \" \", | |
1488 \" ... . \", | |
1489 \" .+. .. \", | |
1490 \" .@. .#. \", | |
1491 \" .$. .%@. \", | |
1492 \" .&. .*=-. \", | |
1493 \" .;. .>,'%. \", | |
1494 \" .). .!~{]^. \", | |
1495 \" ./. .(!~{]_. \", | |
1496 \" .:. .!!<>,'%. \", | |
1497 \" .&. .~[}>{*=-. \", | |
1498 \" .$. .|1,2/%@. \", | |
1499 \" .3. .*]4%56. \", | |
1500 \" .7. .^$8#9. \", | |
1501 \" .0. .a7bc. \", | |
1502 \" .d. .efg. \", | |
1503 \" .h. .ij. \", | |
1504 \" .k. .l. \", | |
1505 \" .m. .. \", | |
1506 \" ... . \", | |
1507 \" \", | |
1508 \" \", | |
1509 \" \"}; | |
1510 " | |
1511 'xpm t) | |
1512 "Image for the previous feed button.")) | |
1513 | |
1514 (defconst newsticker--next-feed-image | |
1515 (if (fboundp 'create-image) | |
1516 (create-image "/* XPM */ | |
1517 static char * next_feed_xpm[] = { | |
1518 \"24 24 57 1\", | |
1519 \" c None\", | |
1520 \". c #000000\", | |
1521 \"+ c #6CA2CE\", | |
1522 \"@ c #75ADD6\", | |
1523 \"# c #71A8D3\", | |
1524 \"$ c #79B1DA\", | |
1525 \"% c #7EB7DE\", | |
1526 \"& c #7DB5DD\", | |
1527 \"* c #81BAE1\", | |
1528 \"= c #85BEE4\", | |
1529 \"- c #78B0D9\", | |
1530 \"; c #7FB7DE\", | |
1531 \"> c #83BCE3\", | |
1532 \", c #87C1E6\", | |
1533 \"' c #8AC4E9\", | |
1534 \") c #7BB3DB\", | |
1535 \"! c #80B8DF\", | |
1536 \"~ c #88C2E7\", | |
1537 \"{ c #8BC5E9\", | |
1538 \"] c #8DC7EB\", | |
1539 \"^ c #7CB4DC\", | |
1540 \"/ c #7FB8DF\", | |
1541 \"( c #84BDE3\", | |
1542 \"_ c #7BB3DC\", | |
1543 \": c #83BCE2\", | |
1544 \"< c #87C0E6\", | |
1545 \"[ c #8AC4E8\", | |
1546 \"} c #8BC5EA\", | |
1547 \"| c #8CC6EA\", | |
1548 \"1 c #88C1E6\", | |
1549 \"2 c #89C3E8\", | |
1550 \"3 c #8AC3E8\", | |
1551 \"4 c #7EB6DE\", | |
1552 \"5 c #82BBE1\", | |
1553 \"6 c #86C0E5\", | |
1554 \"7 c #87C0E5\", | |
1555 \"8 c #75ACD6\", | |
1556 \"9 c #7AB2DA\", | |
1557 \"0 c #81B9E0\", | |
1558 \"a c #82BBE2\", | |
1559 \"b c #71A8D2\", | |
1560 \"c c #70A7D1\", | |
1561 \"d c #74ACD6\", | |
1562 \"e c #699FCC\", | |
1563 \"f c #6EA5D0\", | |
1564 \"g c #72A9D4\", | |
1565 \"h c #669CC9\", | |
1566 \"i c #6298C5\", | |
1567 \"j c #679DCA\", | |
1568 \"k c #6BA1CD\", | |
1569 \"l c #6095C3\", | |
1570 \"m c #5C91C0\", | |
1571 \"n c #5F94C2\", | |
1572 \"o c #5B90C0\", | |
1573 \"p c #588CBC\", | |
1574 \"q c #578CBC\", | |
1575 \"r c #5589BA\", | |
1576 \" \", | |
1577 \" \", | |
1578 \" . ... \", | |
1579 \" .. .+. \", | |
1580 \" .@. .#. \", | |
1581 \" .$%. .@. \", | |
1582 \" .&*=. .-. \", | |
1583 \" .;>,'. .). \", | |
1584 \" .!=~{]. .^. \", | |
1585 \" ./(~{]]. ._. \", | |
1586 \" .%:<[}||. .). \", | |
1587 \" .&*=12'3~. .-. \", | |
1588 \" .$45=6<7. .@. \", | |
1589 \" .8940a:. .b. \", | |
1590 \" .cd-)&. .+. \", | |
1591 \" .efg8. .h. \", | |
1592 \" .ijk. .l. \", | |
1593 \" .mn. .o. \", | |
1594 \" .p. .q. \", | |
1595 \" .. .r. \", | |
1596 \" . ... \", | |
1597 \" \", | |
1598 \" \", | |
1599 \" \"}; | |
1600 " | |
1601 'xpm t) | |
1602 "Image for the next feed button.")) | |
1603 | |
1604 (defconst newsticker--mark-read-image | |
1605 (if (fboundp 'create-image) | |
1606 (create-image "/* XPM */ | |
1607 static char * mark_read_xpm[] = { | |
1608 \"24 24 44 1\", | |
1609 \" c None\", | |
1610 \". c #C20000\", | |
1611 \"+ c #BE0000\", | |
1612 \"@ c #C70000\", | |
1613 \"# c #CE0000\", | |
1614 \"$ c #C90000\", | |
1615 \"% c #BD0000\", | |
1616 \"& c #CB0000\", | |
1617 \"* c #D10000\", | |
1618 \"= c #D70000\", | |
1619 \"- c #D30000\", | |
1620 \"; c #CD0000\", | |
1621 \"> c #C60000\", | |
1622 \", c #D40000\", | |
1623 \"' c #DA0000\", | |
1624 \") c #DE0000\", | |
1625 \"! c #DB0000\", | |
1626 \"~ c #D60000\", | |
1627 \"{ c #D00000\", | |
1628 \"] c #DC0000\", | |
1629 \"^ c #E00000\", | |
1630 \"/ c #E40000\", | |
1631 \"( c #E10000\", | |
1632 \"_ c #DD0000\", | |
1633 \": c #D80000\", | |
1634 \"< c #E50000\", | |
1635 \"[ c #E70000\", | |
1636 \"} c #E60000\", | |
1637 \"| c #E20000\", | |
1638 \"1 c #E90000\", | |
1639 \"2 c #E80000\", | |
1640 \"3 c #E30000\", | |
1641 \"4 c #DF0000\", | |
1642 \"5 c #D90000\", | |
1643 \"6 c #CC0000\", | |
1644 \"7 c #C10000\", | |
1645 \"8 c #C30000\", | |
1646 \"9 c #BF0000\", | |
1647 \"0 c #B90000\", | |
1648 \"a c #BC0000\", | |
1649 \"b c #BB0000\", | |
1650 \"c c #B80000\", | |
1651 \"d c #B50000\", | |
1652 \"e c #B70000\", | |
1653 \" \", | |
1654 \" \", | |
1655 \" \", | |
1656 \" . + \", | |
1657 \" +@# $.% \", | |
1658 \" &*= -;> \", | |
1659 \" ,') !~{ \", | |
1660 \" ]^/ (_: \", | |
1661 \" (<[ }|) \", | |
1662 \" <[1 2<| \", | |
1663 \" }222[< \", | |
1664 \" }}}< \", | |
1665 \" 333| \", | |
1666 \" _4^4)] \", | |
1667 \" ~:' 5=- \", | |
1668 \" 6{- *#$ \", | |
1669 \" 7>$ @89 \", | |
1670 \" 0a+ %bc \", | |
1671 \" ddc edd \", | |
1672 \" ddd ddd \", | |
1673 \" d d \", | |
1674 \" \", | |
1675 \" \", | |
1676 \" \"}; | |
1677 " | |
1678 'xpm t) | |
1679 "Image for the next feed button.")) | |
1680 | |
1681 (defconst newsticker--mark-immortal-image | |
1682 (if (fboundp 'create-image) | |
1683 (create-image "/* XPM */ | |
1684 static char * mark_immortal_xpm[] = { | |
1685 \"24 24 93 2\", | |
1686 \" c None\", | |
1687 \". c #171717\", | |
1688 \"+ c #030303\", | |
1689 \"@ c #000000\", | |
1690 \"# c #181818\", | |
1691 \"$ c #090909\", | |
1692 \"% c #FFC960\", | |
1693 \"& c #FFCB61\", | |
1694 \"* c #FFCB62\", | |
1695 \"= c #FFC961\", | |
1696 \"- c #FFC75F\", | |
1697 \"; c #FFC65E\", | |
1698 \"> c #FFCA61\", | |
1699 \", c #FFCD63\", | |
1700 \"' c #FFCF65\", | |
1701 \") c #FFD065\", | |
1702 \"! c #FFCE64\", | |
1703 \"~ c #FFC35C\", | |
1704 \"{ c #FFC45D\", | |
1705 \"] c #FFD166\", | |
1706 \"^ c #FFD267\", | |
1707 \"/ c #FFD368\", | |
1708 \"( c #FFD167\", | |
1709 \"_ c #FFC05A\", | |
1710 \": c #010101\", | |
1711 \"< c #040404\", | |
1712 \"[ c #FFCC62\", | |
1713 \"} c #FFD569\", | |
1714 \"| c #FFD56A\", | |
1715 \"1 c #FFC860\", | |
1716 \"2 c #FFC25B\", | |
1717 \"3 c #FFBB56\", | |
1718 \"4 c #020202\", | |
1719 \"5 c #060606\", | |
1720 \"6 c #FFC15B\", | |
1721 \"7 c #FFC85F\", | |
1722 \"8 c #FFD469\", | |
1723 \"9 c #FFD66A\", | |
1724 \"0 c #FFBC57\", | |
1725 \"a c #1B1B1B\", | |
1726 \"b c #070707\", | |
1727 \"c c #FFBA55\", | |
1728 \"d c #FFB451\", | |
1729 \"e c #FFB954\", | |
1730 \"f c #FFB350\", | |
1731 \"g c #FFB652\", | |
1732 \"h c #FFBE58\", | |
1733 \"i c #FFCD64\", | |
1734 \"j c #FFD066\", | |
1735 \"k c #FFC059\", | |
1736 \"l c #FFB14E\", | |
1737 \"m c #0B0B0B\", | |
1738 \"n c #FFBB55\", | |
1739 \"o c #FFC15A\", | |
1740 \"p c #FFB552\", | |
1741 \"q c #FFAD4B\", | |
1742 \"r c #080808\", | |
1743 \"s c #FFAF4C\", | |
1744 \"t c #FFB853\", | |
1745 \"u c #FFA948\", | |
1746 \"v c #050505\", | |
1747 \"w c #FFB04E\", | |
1748 \"x c #FFB753\", | |
1749 \"y c #FFBC56\", | |
1750 \"z c #FFC55D\", | |
1751 \"A c #FFC55E\", | |
1752 \"B c #FFC45C\", | |
1753 \"C c #FFBD57\", | |
1754 \"D c #FFB854\", | |
1755 \"E c #FFB34F\", | |
1756 \"F c #FFAB4A\", | |
1757 \"G c #FFA545\", | |
1758 \"H c #FFAA49\", | |
1759 \"I c #FFB04D\", | |
1760 \"J c #FFB551\", | |
1761 \"K c #FFBF58\", | |
1762 \"L c #FFB24F\", | |
1763 \"M c #FFAC4A\", | |
1764 \"N c #FFA646\", | |
1765 \"O c #FFA344\", | |
1766 \"P c #FFA848\", | |
1767 \"Q c #FFB14F\", | |
1768 \"R c #FFAF4D\", | |
1769 \"S c #FFA546\", | |
1770 \"T c #FFA243\", | |
1771 \"U c #FFA445\", | |
1772 \"V c #FFAE4C\", | |
1773 \"W c #FFA444\", | |
1774 \"X c #FFA142\", | |
1775 \"Y c #FF9F41\", | |
1776 \"Z c #0A0A0A\", | |
1777 \"` c #FF9E40\", | |
1778 \" . c #FF9F40\", | |
1779 \" \", | |
1780 \" \", | |
1781 \" \", | |
1782 \" . + @ @ + # \", | |
1783 \" $ @ % & * * = - + + \", | |
1784 \" @ ; > , ' ) ' ! * - ~ @ \", | |
1785 \" @ { > ! ] ^ / / ( ' * ; _ : \", | |
1786 \" < _ ; [ ) / } | } / ] , 1 2 3 4 \", | |
1787 \" 5 6 7 , ] 8 9 9 9 } ^ ! = ~ 0 a \", | |
1788 \" b c 6 - , ] 8 9 9 9 } ^ ! % ~ 0 d 5 \", | |
1789 \" : e _ ; * ) / 8 } } / ] , 1 2 3 f 5 \", | |
1790 \" : g h { = i j ^ / ^ ] ! * ; k e l m \", | |
1791 \" : f n o ; > , ' ) ' ! * - 2 0 p q r \", | |
1792 \" : s g 0 6 ; % > * * = - ~ h t l u r \", | |
1793 \" v u w x y k ~ z A z B o C D E F G b \", | |
1794 \" 5 H I J e 0 h K h C c x L M N . \", | |
1795 \" 4 O P q Q d g x g J L R H S T < \", | |
1796 \" @ T U P F q V q M H N W X + \", | |
1797 \" @ Y T O W G G W O X Y @ \", | |
1798 \" 4 Z ` Y Y Y .` 4 4 \", | |
1799 \" 5 : : @ @ Z \", | |
1800 \" \", | |
1801 \" \", | |
1802 \" \"}; | |
1803 " | |
1804 'xpm t) | |
1805 "Image for the next feed button.")) | |
1806 | |
1807 | |
1808 (defconst newsticker--narrow-image | |
1809 (if (fboundp 'create-image) | |
1810 (create-image "/* XPM */ | |
1811 static char * narrow_xpm[] = { | |
1812 \"24 24 48 1\", | |
1813 \" c None\", | |
1814 \". c #000000\", | |
1815 \"+ c #969696\", | |
1816 \"@ c #9E9E9E\", | |
1817 \"# c #A4A4A4\", | |
1818 \"$ c #AAAAAA\", | |
1819 \"% c #AEAEAE\", | |
1820 \"& c #B1B1B1\", | |
1821 \"* c #B3B3B3\", | |
1822 \"= c #B4B4B4\", | |
1823 \"- c #B2B2B2\", | |
1824 \"; c #AFAFAF\", | |
1825 \"> c #ABABAB\", | |
1826 \", c #A6A6A6\", | |
1827 \"' c #A0A0A0\", | |
1828 \") c #989898\", | |
1829 \"! c #909090\", | |
1830 \"~ c #73AAD4\", | |
1831 \"{ c #7AB2DA\", | |
1832 \"] c #7FB8DF\", | |
1833 \"^ c #84BDE3\", | |
1834 \"/ c #88C2E7\", | |
1835 \"( c #8BC5E9\", | |
1836 \"_ c #8DC7EB\", | |
1837 \": c #8CC6EA\", | |
1838 \"< c #89C3E8\", | |
1839 \"[ c #86BFE5\", | |
1840 \"} c #81BAE1\", | |
1841 \"| c #7BB3DC\", | |
1842 \"1 c #75ACD6\", | |
1843 \"2 c #6DA4CF\", | |
1844 \"3 c #979797\", | |
1845 \"4 c #A3A3A3\", | |
1846 \"5 c #A8A8A8\", | |
1847 \"6 c #ADADAD\", | |
1848 \"7 c #ACACAC\", | |
1849 \"8 c #A9A9A9\", | |
1850 \"9 c #A5A5A5\", | |
1851 \"0 c #9A9A9A\", | |
1852 \"a c #929292\", | |
1853 \"b c #8C8C8C\", | |
1854 \"c c #808080\", | |
1855 \"d c #818181\", | |
1856 \"e c #838383\", | |
1857 \"f c #848484\", | |
1858 \"g c #858585\", | |
1859 \"h c #868686\", | |
1860 \"i c #828282\", | |
1861 \" \", | |
1862 \" \", | |
1863 \" \", | |
1864 \" .................. \", | |
1865 \" .+@#$%&*=*-;>,')!. \", | |
1866 \" .................. \", | |
1867 \" \", | |
1868 \" \", | |
1869 \" .................. \", | |
1870 \" .~{]^/(___:<[}|12. \", | |
1871 \" .................. \", | |
1872 \" \", | |
1873 \" \", | |
1874 \" .................. \", | |
1875 \" .!3@45>666789'0ab. \", | |
1876 \" .................. \", | |
1877 \" \", | |
1878 \" \", | |
1879 \" .................. \", | |
1880 \" .cccdefghhgficccc. \", | |
1881 \" .................. \", | |
1882 \" \", | |
1883 \" \", | |
1884 \" \"}; | |
1885 " | |
1886 'xpm t) | |
1887 "Image for the next feed button.")) | |
1888 | |
1889 (defconst newsticker--get-all-image | |
1890 (if (fboundp 'create-image) | |
1891 (create-image "/* XPM */ | |
1892 static char * get_all_xpm[] = { | |
1893 \"24 24 70 1\", | |
1894 \" c None\", | |
1895 \". c #000000\", | |
1896 \"+ c #F3DA00\", | |
1897 \"@ c #F5DF00\", | |
1898 \"# c #F7E300\", | |
1899 \"$ c #F9E700\", | |
1900 \"% c #FAEA00\", | |
1901 \"& c #FBEC00\", | |
1902 \"* c #FBED00\", | |
1903 \"= c #FCEE00\", | |
1904 \"- c #FAEB00\", | |
1905 \"; c #F9E800\", | |
1906 \"> c #F8E500\", | |
1907 \", c #F6E000\", | |
1908 \"' c #F4DB00\", | |
1909 \") c #F1D500\", | |
1910 \"! c #EFD000\", | |
1911 \"~ c #B7CA00\", | |
1912 \"{ c #BFD100\", | |
1913 \"] c #C5D700\", | |
1914 \"^ c #CBDB00\", | |
1915 \"/ c #CFDF00\", | |
1916 \"( c #D2E200\", | |
1917 \"_ c #D4E400\", | |
1918 \": c #D3E300\", | |
1919 \"< c #D0E000\", | |
1920 \"[ c #CCDD00\", | |
1921 \"} c #C7D800\", | |
1922 \"| c #C1D300\", | |
1923 \"1 c #BACC00\", | |
1924 \"2 c #B1C500\", | |
1925 \"3 c #A8BC00\", | |
1926 \"4 c #20A900\", | |
1927 \"5 c #22AF00\", | |
1928 \"6 c #24B500\", | |
1929 \"7 c #26B900\", | |
1930 \"8 c #27BC00\", | |
1931 \"9 c #27BE00\", | |
1932 \"0 c #28BF00\", | |
1933 \"a c #27BD00\", | |
1934 \"b c #26BA00\", | |
1935 \"c c #25B600\", | |
1936 \"d c #23B100\", | |
1937 \"e c #21AB00\", | |
1938 \"f c #1FA400\", | |
1939 \"g c #1C9B00\", | |
1940 \"h c #21AA00\", | |
1941 \"i c #24B300\", | |
1942 \"j c #25B800\", | |
1943 \"k c #25B700\", | |
1944 \"l c #24B400\", | |
1945 \"m c #23B000\", | |
1946 \"n c #1FA500\", | |
1947 \"o c #1D9E00\", | |
1948 \"p c #20A800\", | |
1949 \"q c #21AC00\", | |
1950 \"r c #23B200\", | |
1951 \"s c #22AD00\", | |
1952 \"t c #1D9F00\", | |
1953 \"u c #20A700\", | |
1954 \"v c #1EA100\", | |
1955 \"w c #1C9C00\", | |
1956 \"x c #1DA000\", | |
1957 \"y c #1B9800\", | |
1958 \"z c #1A9600\", | |
1959 \"A c #1A9700\", | |
1960 \"B c #1A9500\", | |
1961 \"C c #199200\", | |
1962 \"D c #189100\", | |
1963 \"E c #178C00\", | |
1964 \" \", | |
1965 \" \", | |
1966 \" \", | |
1967 \" \", | |
1968 \" ................... \", | |
1969 \" .+@#$%&*=*&-;>,')!. \", | |
1970 \" ................... \", | |
1971 \" \", | |
1972 \" ................... \", | |
1973 \" .~{]^/(___:<[}|123. \", | |
1974 \" ................... \", | |
1975 \" \", | |
1976 \" ................... \", | |
1977 \" .45678909abcdefg. \", | |
1978 \" .h5icj7jklmeno. \", | |
1979 \" .pq5drrmshft. \", | |
1980 \" .fu4h4pnvw. \", | |
1981 \" .oxvxtwy. \", | |
1982 \" .zAAzB. \", | |
1983 \" .CCD. \", | |
1984 \" .E. \", | |
1985 \" . \", | |
1986 \" \", | |
1987 \" \"}; | |
1988 " | |
1989 'xpm t) | |
1990 "Image for the next feed button.")) | |
1991 | |
1992 | |
1993 (defconst newsticker--update-image | |
1994 (if (fboundp 'create-image) | |
1995 (create-image "/* XPM */ | |
1996 static char * update_xpm[] = { | |
1997 \"24 24 37 1\", | |
1998 \" c None\", | |
1999 \". c #076D00\", | |
2000 \"+ c #0A8600\", | |
2001 \"@ c #0A8800\", | |
2002 \"# c #098400\", | |
2003 \"$ c #087200\", | |
2004 \"% c #087900\", | |
2005 \"& c #098500\", | |
2006 \"* c #098100\", | |
2007 \"= c #087600\", | |
2008 \"- c #097E00\", | |
2009 \"; c #097F00\", | |
2010 \"> c #0A8700\", | |
2011 \", c #0A8C00\", | |
2012 \"' c #097C00\", | |
2013 \") c #098300\", | |
2014 \"! c #0A8900\", | |
2015 \"~ c #0A8E00\", | |
2016 \"{ c #0B9200\", | |
2017 \"] c #087700\", | |
2018 \"^ c #076E00\", | |
2019 \"/ c #076C00\", | |
2020 \"( c #076B00\", | |
2021 \"_ c #076A00\", | |
2022 \": c #076900\", | |
2023 \"< c #076800\", | |
2024 \"[ c #066700\", | |
2025 \"} c #066500\", | |
2026 \"| c #066400\", | |
2027 \"1 c #066300\", | |
2028 \"2 c #066600\", | |
2029 \"3 c #066200\", | |
2030 \"4 c #076700\", | |
2031 \"5 c #065E00\", | |
2032 \"6 c #066100\", | |
2033 \"7 c #065F00\", | |
2034 \"8 c #066000\", | |
2035 \" \", | |
2036 \" \", | |
2037 \" \", | |
2038 \" . +@@@+# \", | |
2039 \" $% &@ +* \", | |
2040 \" =-# ; \", | |
2041 \" %*>, ' \", | |
2042 \" ')!~{ = \", | |
2043 \" ]$ \", | |
2044 \" ^ ^ \", | |
2045 \" . . \", | |
2046 \" / ( \", | |
2047 \" _ : \", | |
2048 \" < [ \", | |
2049 \" } | \", | |
2050 \" [[ \", | |
2051 \" 1 $.:23 \", | |
2052 \" 3 4}35 \", | |
2053 \" 6 655 \", | |
2054 \" 76 85 55 \", | |
2055 \" 5555555 5 \", | |
2056 \" \", | |
2057 \" \", | |
2058 \" \"}; | |
2059 " | |
2060 'xpm t) | |
2061 "Image for the update button.")) | |
2062 | |
2063 (defconst newsticker--browse-image | |
2064 (if (fboundp 'create-image) | |
2065 (create-image "/* XPM */ | |
2066 static char * visit_xpm[] = { | |
2067 \"24 24 39 1\", | |
2068 \" c None\", | |
2069 \". c #000000\", | |
2070 \"+ c #FFFFFF\", | |
2071 \"@ c #00E63D\", | |
2072 \"# c #00E83E\", | |
2073 \"$ c #00E73D\", | |
2074 \"% c #00E93E\", | |
2075 \"& c #00E63C\", | |
2076 \"* c #00E53C\", | |
2077 \"= c #00E23B\", | |
2078 \"- c #00E33B\", | |
2079 \"; c #00E83D\", | |
2080 \"> c #00E13A\", | |
2081 \", c #00DD38\", | |
2082 \"' c #00DE38\", | |
2083 \") c #00E23A\", | |
2084 \"! c #00E43C\", | |
2085 \"~ c #00DF39\", | |
2086 \"{ c #00DB37\", | |
2087 \"] c #00D634\", | |
2088 \"^ c #00D734\", | |
2089 \"/ c #00E039\", | |
2090 \"( c #00DC37\", | |
2091 \"_ c #00D835\", | |
2092 \": c #00D332\", | |
2093 \"< c #00CD2F\", | |
2094 \"[ c #00DB36\", | |
2095 \"} c #00D433\", | |
2096 \"| c #00CF30\", | |
2097 \"1 c #00DA36\", | |
2098 \"2 c #00D936\", | |
2099 \"3 c #00D533\", | |
2100 \"4 c #00D131\", | |
2101 \"5 c #00CE2F\", | |
2102 \"6 c #00CC2F\", | |
2103 \"7 c #00CA2D\", | |
2104 \"8 c #00C62B\", | |
2105 \"9 c #00C52A\", | |
2106 \"0 c #00BE27\", | |
2107 \" \", | |
2108 \" \", | |
2109 \" . \", | |
2110 \" .+. \", | |
2111 \" .+++. \", | |
2112 \" .++.++. \", | |
2113 \" .++.@.++. \", | |
2114 \" .++.##$.++. \", | |
2115 \" .++.%%%#&.++. \", | |
2116 \" .++.$%%%#*=.++. \", | |
2117 \" .++.-@;##$*>,.++. \", | |
2118 \" .++.')!&@@*=~{].++. \", | |
2119 \" .++.^{~>---)/(_:<.++. \", | |
2120 \" .++.^[,~/~'(_}|.++. \", | |
2121 \" .++.]_1[12^:|.++. \", | |
2122 \" .++.:}33:45.++. \", | |
2123 \" .++.<5567.++. \", | |
2124 \" .++.889.++. \", | |
2125 \" .++.0.++. \", | |
2126 \" .++.++. \", | |
2127 \" .+++. \", | |
2128 \" .+. \", | |
2129 \" . \", | |
2130 \" \"}; | |
2131 " | |
2132 'xpm t) | |
2133 "Image for the browse button.")) | |
2134 | |
2135 | |
2136 (defvar newsticker-tool-bar-map | |
2137 (if (featurep 'xemacs) | |
2138 nil | |
2139 (let ((tool-bar-map (make-sparse-keymap))) | |
2140 (define-key tool-bar-map [newsticker-sep-1] | |
2141 (list 'menu-item "--double-line")) | |
2142 (define-key tool-bar-map [newsticker-browse-url] | |
2143 (list 'menu-item "newsticker-browse-url" 'newsticker-browse-url | |
2144 :visible t | |
2145 :help "Browse URL for item at point" | |
2146 :image newsticker--browse-image)) | |
2147 (define-key tool-bar-map [newsticker-buffer-force-update] | |
2148 (list 'menu-item "newsticker-buffer-force-update" | |
2149 'newsticker-buffer-force-update | |
2150 :visible t | |
2151 :help "Update newsticker buffer" | |
2152 :image newsticker--update-image | |
2153 :enable '(not newsticker--buffer-uptodate-p))) | |
2154 (define-key tool-bar-map [newsticker-get-all-news] | |
2155 (list 'menu-item "newsticker-get-all-news" 'newsticker-get-all-news | |
2156 :visible t | |
2157 :help "Get news for all feeds" | |
2158 :image newsticker--get-all-image)) | |
2159 (define-key tool-bar-map [newsticker-mark-item-at-point-as-read] | |
2160 (list 'menu-item "newsticker-mark-item-at-point-as-read" | |
2161 'newsticker-mark-item-at-point-as-read | |
2162 :visible t | |
2163 :image newsticker--mark-read-image | |
2164 :help "Mark current item as read" | |
2165 :enable '(newsticker-item-not-old-p))) | |
2166 (define-key tool-bar-map [newsticker-mark-item-at-point-as-immortal] | |
2167 (list 'menu-item "newsticker-mark-item-at-point-as-immortal" | |
2168 'newsticker-mark-item-at-point-as-immortal | |
2169 :visible t | |
2170 :image newsticker--mark-immortal-image | |
2171 :help "Mark current item as immortal" | |
2172 :enable '(newsticker-item-not-immortal-p))) | |
2173 (define-key tool-bar-map [newsticker-toggle-auto-narrow-to-feed] | |
2174 (list 'menu-item "newsticker-toggle-auto-narrow-to-feed" | |
2175 'newsticker-toggle-auto-narrow-to-feed | |
2176 :visible t | |
2177 :help "Toggle visibility of other feeds" | |
2178 :image newsticker--narrow-image)) | |
2179 (define-key tool-bar-map [newsticker-next-feed] | |
2180 (list 'menu-item "newsticker-next-feed" 'newsticker-next-feed | |
2181 :visible t | |
2182 :help "Go to next feed" | |
2183 :image newsticker--next-feed-image | |
2184 :enable '(newsticker-next-feed-available-p))) | |
2185 (define-key tool-bar-map [newsticker-next-item] | |
2186 (list 'menu-item "newsticker-next-item" 'newsticker-next-item | |
2187 :visible t | |
2188 :help "Go to next item" | |
2189 :image newsticker--next-item-image | |
2190 :enable '(newsticker-next-item-available-p))) | |
2191 (define-key tool-bar-map [newsticker-previous-item] | |
2192 (list 'menu-item "newsticker-previous-item" 'newsticker-previous-item | |
2193 :visible t | |
2194 :help "Go to previous item" | |
2195 :image newsticker--previous-item-image | |
2196 :enable '(newsticker-previous-item-available-p))) | |
2197 (define-key tool-bar-map [newsticker-previous-feed] | |
2198 (list 'menu-item "newsticker-previous-feed" 'newsticker-previous-feed | |
2199 :visible t | |
2200 :help "Go to previous feed" | |
2201 :image newsticker--previous-feed-image | |
2202 :enable '(newsticker-previous-feed-available-p))) | |
2203 ;; standard icons / actions | |
2204 (tool-bar-add-item "close" | |
2205 'newsticker-close-buffer | |
2206 'newsticker-close-buffer | |
2207 :help "Close newsticker buffer") | |
2208 (tool-bar-add-item "preferences" | |
2209 'newsticker-customize | |
2210 'newsticker-customize | |
2211 :help "Customize newsticker") | |
2212 tool-bar-map))) | |
2213 | |
2214 ;; ====================================================================== | |
2215 ;;; Newsticker mode | |
2216 ;; ====================================================================== | |
2217 | |
2218 (define-derived-mode newsticker-mode fundamental-mode | |
2219 "NewsTicker" | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2220 "Viewing news feeds in Emacs." |
65468 | 2221 (set (make-local-variable 'tool-bar-map) newsticker-tool-bar-map) |
2222 (set (make-local-variable 'imenu-sort-function) nil) | |
2223 (set (make-local-variable 'scroll-conservatively) 999) | |
2224 (setq imenu-create-index-function 'newsticker--imenu-create-index) | |
2225 (setq imenu-default-goto-function 'newsticker--imenu-goto) | |
2226 (setq buffer-read-only t) | |
2227 (auto-fill-mode -1) ;; turn auto-fill off! | |
2228 (font-lock-mode -1) ;; turn off font-lock!! | |
2229 (set (make-local-variable 'font-lock-defaults) nil) | |
2230 (set (make-local-variable 'line-move-ignore-invisible) t) | |
2231 (setq mode-line-format | |
2232 (list "-" | |
2233 'mode-line-mule-info | |
2234 'mode-line-modified | |
2235 'mode-line-frame-identification | |
2236 " Newsticker (" | |
2237 '(newsticker--buffer-uptodate-p | |
2238 "up to date" | |
2239 "NEED UPDATE") | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2240 ") " |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2241 '(:eval (format "[%d]" (length newsticker--process-ids))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2242 " -- " |
65468 | 2243 '(:eval (newsticker--buffer-get-feed-title-at-point)) |
2244 ": " | |
2245 '(:eval (newsticker--buffer-get-item-title-at-point)) | |
2246 " %-")) | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2247 (add-to-invisibility-spec 't) |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2248 (unless newsticker-show-all-news-elements |
65468 | 2249 (add-to-invisibility-spec 'extra)) |
2250 (newsticker--buffer-set-uptodate nil)) | |
2251 | |
2252 ;; refine its mode-map | |
2253 (define-key newsticker-mode-map "sO" 'newsticker-show-old-items) | |
2254 (define-key newsticker-mode-map "hO" 'newsticker-hide-old-items) | |
2255 (define-key newsticker-mode-map "sa" 'newsticker-show-all-desc) | |
2256 (define-key newsticker-mode-map "ha" 'newsticker-hide-all-desc) | |
2257 (define-key newsticker-mode-map "sf" 'newsticker-show-feed-desc) | |
2258 (define-key newsticker-mode-map "hf" 'newsticker-hide-feed-desc) | |
2259 (define-key newsticker-mode-map "so" 'newsticker-show-old-item-desc) | |
2260 (define-key newsticker-mode-map "ho" 'newsticker-hide-old-item-desc) | |
2261 (define-key newsticker-mode-map "sn" 'newsticker-show-new-item-desc) | |
2262 (define-key newsticker-mode-map "hn" 'newsticker-hide-new-item-desc) | |
2263 (define-key newsticker-mode-map "se" 'newsticker-show-entry) | |
2264 (define-key newsticker-mode-map "he" 'newsticker-hide-entry) | |
2265 (define-key newsticker-mode-map "sx" 'newsticker-show-extra) | |
2266 (define-key newsticker-mode-map "hx" 'newsticker-hide-extra) | |
2267 | |
2268 (define-key newsticker-mode-map " " 'scroll-up) | |
2269 (define-key newsticker-mode-map "q" 'newsticker-close-buffer) | |
2270 (define-key newsticker-mode-map "p" 'newsticker-previous-item) | |
2271 (define-key newsticker-mode-map "P" 'newsticker-previous-new-item) | |
2272 (define-key newsticker-mode-map "F" 'newsticker-previous-feed) | |
2273 (define-key newsticker-mode-map "\t" 'newsticker-next-item) | |
2274 (define-key newsticker-mode-map "n" 'newsticker-next-item) | |
2275 (define-key newsticker-mode-map "N" 'newsticker-next-new-item) | |
2276 (define-key newsticker-mode-map "f" 'newsticker-next-feed) | |
2277 (define-key newsticker-mode-map "M" 'newsticker-mark-all-items-as-read) | |
2278 (define-key newsticker-mode-map "m" | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2279 '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
|
2280 (define-key newsticker-mode-map "o" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2281 'newsticker-mark-item-at-point-as-read) |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2282 (define-key newsticker-mode-map "O" |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2283 'newsticker-mark-all-items-at-point-as-read) |
65468 | 2284 (define-key newsticker-mode-map "G" 'newsticker-get-all-news) |
2285 (define-key newsticker-mode-map "g" 'newsticker-get-news-at-point) | |
2286 (define-key newsticker-mode-map "u" 'newsticker-buffer-update) | |
2287 (define-key newsticker-mode-map "U" 'newsticker-buffer-force-update) | |
2288 (define-key newsticker-mode-map "a" 'newsticker-add-url) | |
2289 | |
2290 (define-key newsticker-mode-map "i" | |
2291 'newsticker-mark-item-at-point-as-immortal) | |
2292 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2293 (define-key newsticker-mode-map "xf" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2294 'newsticker-toggle-auto-narrow-to-feed) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2295 (define-key newsticker-mode-map "xi" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2296 'newsticker-toggle-auto-narrow-to-item) |
65468 | 2297 |
2298 ;; maps for the clickable portions | |
2299 (defvar newsticker--url-keymap (make-sparse-keymap) | |
2300 "Key map for click-able headings in the newsticker buffer.") | |
2301 (define-key newsticker--url-keymap [mouse-2] | |
2302 'newsticker-mouse-browse-url) | |
2303 (define-key newsticker--url-keymap "\n" | |
2304 'newsticker-browse-url) | |
2305 (define-key newsticker--url-keymap "\C-m" | |
2306 'newsticker-browse-url) | |
2307 (define-key newsticker--url-keymap [(control return)] | |
2308 'newsticker-handle-url) | |
2309 | |
2310 ;; newsticker menu | |
2311 (defvar newsticker-menu (make-sparse-keymap "Newsticker")) | |
2312 | |
2313 (define-key newsticker-menu [newsticker-browse-url] | |
2314 '("Browse URL for item at point" . newsticker-browse-url)) | |
2315 (define-key newsticker-menu [newsticker-separator-1] | |
2316 '("--")) | |
2317 (define-key newsticker-menu [newsticker-buffer-update] | |
2318 '("Update buffer" . newsticker-buffer-update)) | |
2319 (define-key newsticker-menu [newsticker-separator-2] | |
2320 '("--")) | |
2321 (define-key newsticker-menu [newsticker-get-all-news] | |
2322 '("Get news from all feeds" . newsticker-get-all-news)) | |
2323 (define-key newsticker-menu [newsticker-get-news-at-point] | |
2324 '("Get news from feed at point" . newsticker-get-news-at-point)) | |
2325 (define-key newsticker-menu [newsticker-separator-3] | |
2326 '("--")) | |
2327 (define-key newsticker-menu [newsticker-mark-all-items-as-read] | |
2328 '("Mark all items as read" . newsticker-mark-all-items-as-read)) | |
2329 (define-key newsticker-menu [newsticker-mark-all-items-at-point-as-read] | |
2330 '("Mark all items in feed at point as read" . | |
2331 newsticker-mark-all-items-at-point-as-read)) | |
2332 (define-key newsticker-menu [newsticker-mark-item-at-point-as-read] | |
2333 '("Mark item at point as read" . | |
2334 newsticker-mark-item-at-point-as-read)) | |
2335 (define-key newsticker-menu [newsticker-mark-item-at-point-as-immortal] | |
2336 '("Toggle immortality for item at point" . | |
2337 newsticker-mark-item-at-point-as-immortal)) | |
2338 (define-key newsticker-menu [newsticker-separator-4] | |
2339 '("--")) | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2340 (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
|
2341 '("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
|
2342 (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
|
2343 '("Narrow to single news feed" . newsticker-toggle-auto-narrow-to-feed)) |
65468 | 2344 (define-key newsticker-menu [newsticker-hide-old-items] |
2345 '("Hide old items" . newsticker-hide-old-items)) | |
2346 (define-key newsticker-menu [newsticker-show-old-items] | |
2347 '("Show old items" . newsticker-show-old-items)) | |
2348 (define-key newsticker-menu [newsticker-next-item] | |
2349 '("Go to next item" . newsticker-next-item)) | |
2350 (define-key newsticker-menu [newsticker-previous-item] | |
2351 '("Go to previous item" . newsticker-previous-item)) | |
2352 | |
2353 ;; bind menu to mouse | |
2354 (define-key newsticker-mode-map [down-mouse-3] newsticker-menu) | |
2355 ;; Put menu in menu-bar | |
2356 (define-key newsticker-mode-map [menu-bar Newsticker] | |
2357 (cons "Newsticker" newsticker-menu)) | |
2358 | |
2359 | |
2360 ;; ====================================================================== | |
2361 ;;; shortcuts | |
2362 ;; ====================================================================== | |
2363 (defsubst newsticker--title (item) | |
2364 "Return title of ITEM." | |
2365 (nth 0 item)) | |
2366 (defsubst newsticker--desc (item) | |
2367 "Return description of ITEM." | |
2368 (nth 1 item)) | |
2369 (defsubst newsticker--link (item) | |
2370 "Return link of ITEM." | |
2371 (nth 2 item)) | |
2372 (defsubst newsticker--time (item) | |
2373 "Return time of ITEM." | |
2374 (nth 3 item)) | |
2375 (defsubst newsticker--age (item) | |
2376 "Return age of ITEM." | |
2377 (nth 4 item)) | |
2378 (defsubst newsticker--pos (item) | |
2379 "Return position/index of ITEM." | |
2380 (nth 5 item)) | |
2381 (defsubst newsticker--preformatted-contents (item) | |
2382 "Return pre-formatted text of ITEM." | |
2383 (nth 6 item)) | |
2384 (defsubst newsticker--preformatted-title (item) | |
2385 "Return pre-formatted title of ITEM." | |
2386 (nth 7 item)) | |
2387 (defsubst newsticker--extra (item) | |
2388 "Return extra attributes of ITEM." | |
2389 (nth 8 item)) | |
2390 (defsubst newsticker--guid (item) | |
2391 "Return guid of ITEM." | |
2392 (let ((guid (assoc 'guid (newsticker--extra item)))) | |
2393 (if (stringp guid) | |
2394 guid | |
2395 (car (xml-node-children guid))))) | |
2396 (defsubst newsticker--enclosure (item) | |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
2397 "Return enclosure element of ITEM in the form \(...FIXME...\) or nil." |
65468 | 2398 (let ((enclosure (assoc 'enclosure (newsticker--extra item)))) |
2399 (if enclosure | |
2400 (xml-node-attributes enclosure)))) | |
2401 | |
2402 ;; ====================================================================== | |
2403 ;;; User fun | |
2404 ;; ====================================================================== | |
2405 | |
65998
e6b90c8b34d8
(newsticker-start, newsticker-show-news): Add autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents:
65638
diff
changeset
|
2406 ;;;###autoload |
65468 | 2407 (defun newsticker-start (&optional do-not-complain-if-running) |
2408 "Start the newsticker. | |
2409 Start the timers for display and retrieval. If the newsticker, i.e. the | |
2410 timers, are running already a warning message is printed unless | |
2411 DO-NOT-COMPLAIN-IF-RUNNING is not nil. | |
2412 Run `newsticker-start-hook' if newsticker was not running already." | |
2413 (interactive) | |
2414 (let ((running (newsticker-running-p))) | |
2415 ;; read old cache if it exists and newsticker is not running | |
2416 (unless running | |
2417 (let* ((coding-system-for-read 'utf-8) | |
2418 (buf (find-file-noselect newsticker-cache-filename))) | |
2419 (when buf | |
2420 (set-buffer buf) | |
2421 (goto-char (point-min)) | |
2422 (condition-case nil | |
2423 (setq newsticker--cache (read buf)) | |
2424 (error | |
2425 (message "Error while reading newsticker cache file!") | |
2426 (setq newsticker--cache nil)))))) | |
2427 ;; start retrieval timers -- for sake of simplicity we will start | |
2428 ;; one timer for each feed | |
2429 (mapc (lambda (item) | |
2430 (let* ((feed-name (car item)) | |
2431 (start-time (nth 2 item)) | |
2432 (interval (or (nth 3 item) | |
2433 newsticker-retrieval-interval)) | |
2434 (timer (assoc (car item) | |
2435 newsticker--retrieval-timer-list))) | |
2436 (if timer | |
2437 (or do-not-complain-if-running | |
2438 (message "Timer for %s is running already!" | |
2439 feed-name)) | |
2440 (newsticker--debug-msg "Starting timer for %s: %s, %d" | |
2441 feed-name start-time interval) | |
2442 ;; do not repeat retrieval if interval not positive | |
2443 (if (<= interval 0) | |
2444 (setq interval nil)) | |
2445 ;; Suddenly XEmacs doesn't like start-time 0 | |
2446 (if (or (not start-time) | |
2447 (and (numberp start-time) (= start-time 0))) | |
2448 (setq start-time 1)) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2449 ;; (message "start-time %s" start-time) |
65468 | 2450 (setq timer (run-at-time start-time interval |
2451 'newsticker-get-news feed-name)) | |
2452 (if interval | |
2453 (add-to-list 'newsticker--retrieval-timer-list | |
2454 (cons feed-name timer)))))) | |
2455 (append newsticker-url-list-defaults newsticker-url-list)) | |
2456 (unless running | |
2457 (run-hooks 'newsticker-start-hook) | |
2458 (message "Newsticker started!")))) | |
2459 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2460 ;;;###autoload |
65468 | 2461 (defun newsticker-start-ticker () |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2462 "Start newsticker's ticker (but not the news retrieval). |
65468 | 2463 Start display timer for the actual ticker if wanted and not |
2464 running already." | |
2465 (interactive) | |
2466 (if (and (> newsticker-display-interval 0) | |
2467 (not newsticker--display-timer)) | |
2468 (setq newsticker--display-timer | |
2469 (run-at-time newsticker-display-interval | |
2470 newsticker-display-interval | |
2471 '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
|
2472 |
65468 | 2473 (defun newsticker-stop () |
2474 "Stop the newsticker and the newsticker-ticker. | |
2475 Cancel the timers for display and retrieval. Run `newsticker-stop-hook' | |
2476 if newsticker has been running." | |
2477 (interactive) | |
2478 (newsticker--cache-update t) | |
2479 (newsticker-stop-ticker) | |
2480 (when (newsticker-running-p) | |
2481 (mapc (lambda (name-and-timer) | |
2482 (cancel-timer (cdr name-and-timer))) | |
2483 newsticker--retrieval-timer-list) | |
2484 (setq newsticker--retrieval-timer-list nil) | |
2485 (run-hooks 'newsticker-stop-hook) | |
2486 (message "Newsticker stopped!"))) | |
2487 | |
2488 (defun newsticker-stop-ticker () | |
2489 "Stop newsticker's ticker (but not the news retrieval)." | |
2490 (interactive) | |
2491 (when newsticker--display-timer | |
2492 (cancel-timer newsticker--display-timer) | |
2493 (setq newsticker--display-timer nil))) | |
2494 | |
2495 ;; 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
|
2496 ;;;###autoload |
65468 | 2497 (defun newsticker-show-news () |
2498 "Switch to newsticker buffer. You may want to bind this to a key." | |
2499 (interactive) | |
2500 (newsticker-start t) ;; will start only if not running | |
2501 (newsticker-buffer-update) | |
2502 (switch-to-buffer "*newsticker*")) | |
2503 | |
2504 (defun newsticker-buffer-force-update () | |
2505 "Update the newsticker buffer, even if not necessary." | |
2506 (interactive) | |
2507 (newsticker-buffer-update t)) | |
2508 | |
2509 (defun newsticker-buffer-update (&optional force) | |
2510 "Update the *newsticker* buffer. | |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
2511 Unless FORCE is t this is done only if necessary, i.e. when the |
65468 | 2512 *newsticker* buffer is not up-to-date." |
2513 (interactive) | |
2514 ;; bring cache data into proper order.... | |
2515 (newsticker--cache-sort) | |
2516 ;; fill buffer | |
2517 (save-excursion | |
2518 (let ((buf (get-buffer "*newsticker*"))) | |
2519 (if buf | |
2520 (switch-to-buffer buf) | |
2521 (switch-to-buffer (get-buffer-create "*newsticker*")) | |
2522 (newsticker--buffer-set-uptodate nil))) | |
2523 (when (or force | |
2524 (not newsticker--buffer-uptodate-p)) | |
2525 (message "Preparing newsticker buffer...") | |
2526 (setq buffer-undo-list t) | |
2527 (let ((inhibit-read-only t)) | |
2528 (set-buffer-modified-p nil) | |
2529 (erase-buffer) | |
2530 (newsticker-mode) | |
2531 ;; Emacs 21.3.50 does not care if we turn off auto-fill in the | |
2532 ;; definition of newsticker-mode, so we do it here (again) | |
2533 (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
|
2534 |
65468 | 2535 (set-buffer-file-coding-system 'utf-8) |
2536 | |
2537 (if newsticker-use-full-width | |
2538 (set (make-local-variable 'fill-column) (1- (window-width)))) | |
2539 (newsticker--buffer-insert-all-items) | |
2540 | |
2541 ;; FIXME: needed for methods buffer in ecb | |
2542 ;; (set-visited-file-name "*newsticker*") | |
2543 | |
2544 (set-buffer-modified-p nil) | |
2545 (newsticker-hide-all-desc) | |
2546 (if newsticker-hide-old-items-in-newsticker-buffer | |
2547 (newsticker-hide-old-items)) | |
2548 (if newsticker-show-descriptions-of-new-items | |
2549 (newsticker-show-new-item-desc)) | |
2550 ) | |
2551 (message "")) | |
2552 (newsticker--buffer-set-uptodate t) | |
2553 (run-hooks 'newsticker-buffer-change-hook))) | |
2554 | |
2555 (defun newsticker-get-all-news () | |
2556 "Launch retrieval of news from all configured newsticker sites. | |
2557 This does NOT start the retrieval timers." | |
2558 (interactive) | |
2559 ;; launch retrieval of news | |
2560 (mapc (lambda (item) | |
2561 (newsticker-get-news (car item))) | |
2562 (append newsticker-url-list-defaults newsticker-url-list))) | |
2563 | |
2564 (defun newsticker-get-news-at-point () | |
2565 "Launch retrieval of news for the feed point is in. | |
2566 This does NOT start the retrieval timers." | |
2567 (interactive) | |
2568 ;; launch retrieval of news | |
2569 (let ((feed (get-text-property (point) 'feed))) | |
2570 (when feed | |
2571 (newsticker--debug-msg "Getting news for %s" (symbol-name feed)) | |
2572 (newsticker-get-news (symbol-name feed))))) | |
2573 | |
2574 (defun newsticker-add-url (url name) | |
2575 "Add given URL under given NAME to `newsticker-url-list'. | |
2576 If URL is nil it is searched at point." | |
2577 (interactive | |
2578 (list | |
2579 (read-string "URL: " | |
2580 (save-excursion | |
2581 (end-of-line) | |
2582 (and | |
2583 (re-search-backward | |
2584 "http://" | |
2585 (if (> (point) (+ (point-min) 100)) | |
2586 (- (point) 100) | |
2587 (point-min)) | |
2588 t) | |
2589 (re-search-forward | |
2590 "http://[-a-zA-Z0-9&/_.]*" | |
2591 (if (< (point) (- (point-max) 200)) | |
2592 (+ (point) 200) | |
2593 (point-max)) | |
2594 t) | |
2595 (buffer-substring-no-properties (match-beginning 0) | |
2596 (match-end 0))))) | |
2597 (read-string "Name: "))) | |
2598 (add-to-list 'newsticker-url-list (list name url nil nil nil) t) | |
2599 (customize-variable 'newsticker-url-list)) | |
2600 | |
2601 (defun newsticker-w3m-show-inline-images () | |
2602 "Show inline images in visible text ranges. | |
2603 In-line images in invisible text ranges are hidden. This function | |
2604 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
|
2605 `newsticker-html-renderer' is set to `w3m-region'." |
65468 | 2606 (interactive) |
2607 (if (eq newsticker-html-renderer 'w3m-region) | |
2608 (let ((inhibit-read-only t)) | |
2609 (save-excursion | |
2610 (save-restriction | |
2611 (widen) | |
2612 (goto-char (point-min)) | |
2613 (let ((pos (point))) | |
2614 (while pos | |
2615 (setq pos (next-single-property-change pos 'w3m-image)) | |
2616 (when pos | |
2617 (goto-char pos) | |
2618 (when (get-text-property pos 'w3m-image) | |
2619 (let ((invis (newsticker--lists-intersect-p | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2620 (get-text-property (1- (point)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2621 'invisible) |
65468 | 2622 buffer-invisibility-spec))) |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2623 (unless (car (get-text-property (1- (point)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2624 'display)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2625 (unless invis |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2626 (w3m-toggle-inline-image t))))))))))))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2627 |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2628 (defadvice w3m-insert-image (after newsticker activate) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2629 (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
|
2630 |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2631 (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
|
2632 "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
|
2633 between BEG and END." |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2634 (when (string= (buffer-name) "*newsticker*") |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2635 (save-excursion |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2636 (newsticker--buffer-beginning-of-item) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2637 (let* ((pos (point)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2638 (feed (get-text-property pos 'feed)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2639 (age (get-text-property pos 'nt-age)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2640 (title (get-text-property pos 'nt-title)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2641 (guid (get-text-property pos 'nt-guid)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2642 (nt-desc (get-text-property pos 'nt-desc)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2643 (item (newsticker--cache-contains newsticker--cache |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2644 feed title nt-desc |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2645 nil nil guid)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2646 (desc-beg (newsticker--buffer-goto '(desc))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2647 (desc-end (newsticker--buffer-end-of-item))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2648 ;;(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
|
2649 (add-text-properties beg end (list 'invisible |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2650 (get-text-property end 'invisible))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2651 ;;(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
|
2652 ;; beg feed title) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2653 (if item |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2654 (newsticker--cache-set-preformatted-contents |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2655 item (buffer-substring desc-beg desc-end)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2656 (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
|
2657 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
|
2658 |
65468 | 2659 ;; ====================================================================== |
2660 ;;; keymap stuff | |
2661 ;; ====================================================================== | |
2662 (defun newsticker-close-buffer () | |
2663 "Close the newsticker buffer." | |
2664 (interactive) | |
2665 (newsticker--cache-update t) | |
2666 (bury-buffer)) | |
2667 | |
2668 (defun newsticker-next-new-item (&optional do-not-wrap-at-eob) | |
2669 "Go to next new news item. | |
2670 If no new item is found behind point, search is continued at | |
2671 beginning of buffer unless optional argument DO-NOT-WRAP-AT-EOB | |
2672 is non-nil." | |
2673 (interactive) | |
2674 (widen) | |
2675 (let ((go-ahead t)) | |
2676 (while go-ahead | |
2677 (unless (newsticker--buffer-goto '(item) 'new) | |
2678 ;; found nothing -- wrap | |
2679 (unless do-not-wrap-at-eob | |
2680 (goto-char (point-min)) | |
2681 (newsticker-next-new-item t)) | |
2682 (setq go-ahead nil)) | |
2683 (unless (newsticker--lists-intersect-p | |
2684 (get-text-property (point) 'invisible) | |
2685 buffer-invisibility-spec) | |
2686 ;; this item is invisible -- continue search | |
2687 (setq go-ahead nil)))) | |
2688 (run-hooks 'newsticker-select-item-hook) | |
2689 (point)) | |
2690 | |
2691 (defun newsticker-previous-new-item (&optional do-not-wrap-at-bob) | |
2692 "Go to previous new news item. | |
2693 If no new item is found before point, search is continued at | |
2694 beginning of buffer unless optional argument DO-NOT-WRAP-AT-BOB | |
2695 is non-nil." | |
2696 (interactive) | |
2697 (widen) | |
2698 (let ((go-ahead t)) | |
2699 (while go-ahead | |
2700 (unless (newsticker--buffer-goto '(item) 'new t) | |
2701 (unless do-not-wrap-at-bob | |
2702 (goto-char (point-max)) | |
2703 (newsticker--buffer-goto '(item) 'new t))) | |
2704 (unless (newsticker--lists-intersect-p | |
2705 (get-text-property (point) 'invisible) | |
2706 buffer-invisibility-spec) | |
2707 (setq go-ahead nil)))) | |
2708 (run-hooks 'newsticker-select-item-hook) | |
2709 (point)) | |
2710 | |
2711 (defun newsticker-next-item (&optional do-not-wrap-at-eob) | |
2712 "Go to next news item. | |
2713 Return new buffer position. | |
2714 If no item is found below point, search is continued at beginning | |
2715 of buffer unless optional argument DO-NOT-WRAP-AT-EOB is | |
2716 non-nil." | |
2717 (interactive) | |
2718 (widen) | |
2719 (let ((go-ahead t) | |
2720 (search-list '(item))) | |
2721 (if newsticker--auto-narrow-to-item | |
2722 (setq search-list '(item feed))) | |
2723 (while go-ahead | |
2724 (unless (newsticker--buffer-goto search-list) | |
2725 ;; found nothing -- wrap | |
2726 (unless do-not-wrap-at-eob | |
2727 (goto-char (point-min))) | |
2728 (setq go-ahead nil)) | |
2729 (unless (newsticker--lists-intersect-p | |
2730 (get-text-property (point) 'invisible) | |
2731 buffer-invisibility-spec) | |
2732 (setq go-ahead nil)))) | |
2733 (run-hooks 'newsticker-select-item-hook) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2734 (force-mode-line-update) |
65468 | 2735 (point)) |
2736 | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2737 (defun newsticker-next-item-same-feed () |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2738 "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
|
2739 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
|
2740 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
|
2741 (interactive) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2742 (if newsticker--auto-narrow-to-item |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2743 nil |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2744 (let ((go-ahead t) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2745 (current-pos (point)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2746 (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
|
2747 (while go-ahead |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2748 (unless (newsticker--buffer-goto '(item)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2749 (setq go-ahead nil)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2750 (unless (newsticker--lists-intersect-p |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2751 (get-text-property (point) 'invisible) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2752 buffer-invisibility-spec) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2753 (setq go-ahead nil))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2754 (if (and (> (point) current-pos) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2755 (< (point) end-of-feed)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2756 (point) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2757 (goto-char current-pos) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2758 nil)))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2759 |
65468 | 2760 (defun newsticker-previous-item (&optional do-not-wrap-at-bob) |
2761 "Go to previous news item. | |
2762 Return new buffer position. | |
2763 If no item is found before point, search is continued at | |
2764 beginning of buffer unless optional argument DO-NOT-WRAP-AT-BOB | |
2765 is non-nil." | |
2766 (interactive) | |
2767 (widen) | |
2768 (let ((go-ahead t) | |
2769 (search-list '(item))) | |
2770 (if newsticker--auto-narrow-to-item | |
2771 (setq search-list '(item feed))) | |
2772 (when (bobp) | |
2773 (unless do-not-wrap-at-bob | |
2774 (goto-char (point-max)))) | |
2775 (while go-ahead | |
2776 (if (newsticker--buffer-goto search-list nil t) | |
2777 (unless (newsticker--lists-intersect-p | |
2778 (get-text-property (point) 'invisible) | |
2779 buffer-invisibility-spec) | |
2780 (setq go-ahead nil)) | |
2781 (goto-char (point-min)) | |
2782 (setq go-ahead nil)))) | |
2783 (run-hooks 'newsticker-select-item-hook) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2784 (force-mode-line-update) |
65468 | 2785 (point)) |
2786 | |
2787 (defun newsticker-next-feed () | |
2788 "Go to next news feed. | |
2789 Return new buffer position." | |
2790 (interactive) | |
2791 (widen) | |
2792 (newsticker--buffer-goto '(feed)) | |
2793 (run-hooks 'newsticker-select-feed-hook) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2794 (force-mode-line-update) |
65468 | 2795 (point)) |
2796 | |
2797 (defun newsticker-previous-feed () | |
2798 "Go to previous news feed. | |
2799 Return new buffer position." | |
2800 (interactive) | |
2801 (widen) | |
2802 (newsticker--buffer-goto '(feed) nil t) | |
2803 (run-hooks 'newsticker-select-feed-hook) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
2804 (force-mode-line-update) |
65468 | 2805 (point)) |
2806 | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2807 (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
|
2808 "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
|
2809 (interactive) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2810 (when (or newsticker--buffer-uptodate-p |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2811 (y-or-n-p |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2812 "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
|
2813 (newsticker-mark-all-items-of-feed-as-read |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2814 (get-text-property (point) 'feed)))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2815 |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2816 (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
|
2817 "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
|
2818 (when feed |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2819 (let ((pos (point))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2820 (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
|
2821 (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
|
2822 (newsticker--cache-replace-age newsticker--cache feed 'obsolete |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2823 'old) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2824 (newsticker--cache-update) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2825 (newsticker--buffer-set-uptodate nil) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2826 (newsticker--ticker-text-setup) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2827 (newsticker-buffer-update) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2828 ;; go back to where we came frome |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2829 (goto-char pos) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2830 (end-of-line) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2831 (newsticker--buffer-goto '(feed) nil t)))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2832 |
65468 | 2833 (defun newsticker-mark-all-items-at-point-as-read () |
2834 "Mark all items as read and clear ticker contents." | |
2835 (interactive) | |
2836 (when (or newsticker--buffer-uptodate-p | |
2837 (y-or-n-p | |
2838 "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
|
2839 (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
|
2840 (while (newsticker-next-item-same-feed) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2841 (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
|
2842 (newsticker-next-item t))) |
65468 | 2843 |
2844 (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
|
2845 "Mark item at point as read and move to next item. |
65468 | 2846 If optional argument RESPECT-IMMORTALITY is not nil immortal items do |
2847 not get changed." | |
2848 (interactive) | |
2849 (when (or newsticker--buffer-uptodate-p | |
2850 (y-or-n-p | |
2851 "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
|
2852 (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
|
2853 ;; move forward |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2854 (newsticker-next-item t))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2855 |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2856 (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
|
2857 "Mark item at point as read. |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2858 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
|
2859 not get changed." |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2860 (let ((feed (get-text-property (point) 'feed))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2861 (when feed |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2862 (save-excursion |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2863 (newsticker--buffer-beginning-of-item) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2864 (let ((inhibit-read-only t) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2865 (age (get-text-property (point) 'nt-age)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2866 (title (get-text-property (point) 'nt-title)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2867 (guid (get-text-property (point) 'nt-guid)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2868 (nt-desc (get-text-property (point) 'nt-desc)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2869 (pos (save-excursion (newsticker--buffer-end-of-item))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2870 item) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2871 (when (or (eq age 'new) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2872 (eq age 'obsolete) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2873 (and (eq age 'immortal) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2874 (not respect-immortality))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2875 ;; find item |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2876 (setq item (newsticker--cache-contains newsticker--cache |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2877 feed title nt-desc |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2878 nil nil guid)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2879 ;; mark as old |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2880 (when item |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2881 (setcar (nthcdr 4 item) 'old) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2882 (newsticker--do-forget-preformatted item)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2883 ;; clean up ticker |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2884 (if (or (and (eq age 'new) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2885 newsticker-hide-immortal-items-in-echo-area) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2886 (and (memq age '(old immortal)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2887 (not |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2888 (eq newsticker-hide-old-items-in-newsticker-buffer |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2889 newsticker-hide-immortal-items-in-echo-area)))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2890 (newsticker--ticker-text-remove feed title)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2891 ;; set faces etc. |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2892 (save-excursion |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2893 (save-restriction |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2894 (widen) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2895 (put-text-property (point) pos 'nt-age 'old) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2896 (newsticker--buffer-set-faces (point) pos))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
2897 (set-buffer-modified-p nil))))))) |
65468 | 2898 |
2899 (defun newsticker-mark-item-at-point-as-immortal () | |
2900 "Mark item at point as read." | |
2901 (interactive) | |
2902 (when (or newsticker--buffer-uptodate-p | |
2903 (y-or-n-p | |
2904 "Buffer is not up to date -- really mark this item as read? ")) | |
2905 (let ((feed (get-text-property (point) 'feed)) | |
2906 (item nil)) | |
2907 (when feed | |
2908 (save-excursion | |
2909 (newsticker--buffer-beginning-of-item) | |
2910 (let ((inhibit-read-only t) | |
2911 (oldage (get-text-property (point) 'nt-age)) | |
2912 (title (get-text-property (point) 'nt-title)) | |
2913 (guid (get-text-property (point) 'nt-guid)) | |
2914 (pos (save-excursion (newsticker--buffer-end-of-item)))) | |
2915 (let ((newage 'immortal)) | |
2916 (if (eq oldage 'immortal) | |
2917 (setq newage 'old)) | |
2918 (setq item (newsticker--cache-contains newsticker--cache | |
2919 feed title nil nil nil | |
2920 guid)) | |
2921 ;; change age | |
2922 (when item | |
2923 (setcar (nthcdr 4 item) newage) | |
2924 (newsticker--do-forget-preformatted item)) | |
2925 (if (or (and (eq newage 'immortal) | |
2926 newsticker-hide-immortal-items-in-echo-area) | |
2927 (and (eq newage 'obsolete) | |
2928 newsticker-hide-obsolete-items-in-echo-area) | |
2929 (and (eq oldage 'immortal) | |
2930 (not | |
2931 (eq newsticker-hide-old-items-in-newsticker-buffer | |
2932 newsticker-hide-immortal-items-in-echo-area)))) | |
2933 (newsticker--ticker-text-remove feed title) | |
2934 (newsticker--ticker-text-setup)) | |
2935 (save-excursion | |
2936 (save-restriction | |
2937 (widen) | |
2938 (put-text-property (point) pos 'nt-age newage) | |
2939 (if (eq newage 'immortal) | |
2940 (put-text-property (point) pos 'nt-age 'immortal) | |
2941 (put-text-property (point) pos 'nt-age 'old)) | |
2942 (newsticker--buffer-set-faces (point) pos)))))) | |
2943 (if item | |
2944 (newsticker-next-item t)))))) | |
2945 | |
2946 (defun newsticker-mark-all-items-as-read () | |
2947 "Mark all items as read and clear ticker contents." | |
2948 (interactive) | |
2949 (when (or newsticker--buffer-uptodate-p | |
2950 (y-or-n-p | |
2951 "Buffer is not up to date -- really mark items as read? ")) | |
2952 (newsticker--cache-replace-age newsticker--cache 'any 'new 'old) | |
2953 (newsticker--buffer-set-uptodate nil) | |
2954 (newsticker--ticker-text-setup) | |
2955 (newsticker--cache-update) | |
2956 (newsticker-buffer-update))) | |
2957 | |
2958 (defun newsticker-hide-extra () | |
2959 "Hide the extra elements of items." | |
2960 (interactive) | |
2961 (newsticker--buffer-hideshow 'extra nil) | |
2962 (newsticker--buffer-redraw)) | |
2963 | |
2964 (defun newsticker-show-extra () | |
2965 "Show the extra elements of items." | |
2966 (interactive) | |
2967 (newsticker--buffer-hideshow 'extra t) | |
2968 (newsticker--buffer-redraw)) | |
2969 | |
2970 (defun newsticker-hide-old-item-desc () | |
2971 "Hide the description of old items." | |
2972 (interactive) | |
2973 (newsticker--buffer-hideshow 'desc-old nil) | |
2974 (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
|
2975 |
65468 | 2976 (defun newsticker-show-old-item-desc () |
2977 "Show the description of old items." | |
2978 (interactive) | |
2979 (newsticker--buffer-hideshow 'item-old t) | |
2980 (newsticker--buffer-hideshow 'desc-old t) | |
2981 (newsticker--buffer-redraw)) | |
2982 | |
2983 (defun newsticker-hide-new-item-desc () | |
2984 "Hide the description of new items." | |
2985 (interactive) | |
2986 (newsticker--buffer-hideshow 'desc-new nil) | |
2987 (newsticker--buffer-hideshow 'desc-immortal nil) | |
2988 (newsticker--buffer-hideshow 'desc-obsolete nil) | |
2989 (newsticker--buffer-redraw)) | |
2990 | |
2991 (defun newsticker-show-new-item-desc () | |
2992 "Show the description of new items." | |
2993 (interactive) | |
2994 (newsticker--buffer-hideshow 'desc-new t) | |
2995 (newsticker--buffer-hideshow 'desc-immortal t) | |
2996 (newsticker--buffer-hideshow 'desc-obsolete t) | |
2997 (newsticker--buffer-redraw)) | |
2998 | |
2999 (defun newsticker-hide-feed-desc () | |
3000 "Hide the description of feeds." | |
3001 (interactive) | |
3002 (newsticker--buffer-hideshow 'desc-feed nil) | |
3003 (newsticker--buffer-redraw)) | |
3004 | |
3005 (defun newsticker-show-feed-desc () | |
3006 "Show the description of old items." | |
3007 (interactive) | |
3008 (newsticker--buffer-hideshow 'desc-feed t) | |
3009 (newsticker--buffer-redraw)) | |
3010 | |
3011 (defun newsticker-hide-all-desc () | |
3012 "Hide the descriptions of feeds and all items." | |
3013 (interactive) | |
3014 (newsticker--buffer-hideshow 'desc-feed nil) | |
3015 (newsticker--buffer-hideshow 'desc-immortal nil) | |
3016 (newsticker--buffer-hideshow 'desc-obsolete nil) | |
3017 (newsticker--buffer-hideshow 'desc-new nil) | |
3018 (newsticker--buffer-hideshow 'desc-old nil) | |
3019 (newsticker--buffer-redraw)) | |
3020 | |
3021 (defun newsticker-show-all-desc () | |
3022 "Show the descriptions of feeds and all items." | |
3023 (interactive) | |
3024 (newsticker--buffer-hideshow 'desc-feed t) | |
3025 (newsticker--buffer-hideshow 'desc-immortal t) | |
3026 (newsticker--buffer-hideshow 'desc-obsolete t) | |
3027 (newsticker--buffer-hideshow 'desc-new t) | |
3028 (newsticker--buffer-hideshow 'desc-old t) | |
3029 (newsticker--buffer-redraw)) | |
3030 | |
3031 (defun newsticker-hide-old-items () | |
3032 "Hide old items." | |
3033 (interactive) | |
3034 (newsticker--buffer-hideshow 'desc-old nil) | |
3035 (newsticker--buffer-hideshow 'item-old nil) | |
3036 (newsticker--buffer-redraw)) | |
3037 | |
3038 (defun newsticker-show-old-items () | |
3039 "Show old items." | |
3040 (interactive) | |
3041 (newsticker--buffer-hideshow 'item-old t) | |
3042 (newsticker--buffer-redraw)) | |
3043 | |
3044 (defun newsticker-hide-entry () | |
3045 "Hide description of entry at point." | |
3046 (interactive) | |
3047 (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
|
3048 (let* (pos1 pos2 |
65468 | 3049 (inhibit-read-only t) |
3050 inv-prop org-inv-prop | |
3051 is-invisible) | |
3052 (newsticker--buffer-beginning-of-item) | |
3053 (newsticker--buffer-goto '(desc)) | |
3054 (setq pos1 (max (point-min) (1- (point)))) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3055 (newsticker--buffer-goto '(extra feed item nil)) |
65468 | 3056 (setq pos2 (max (point-min) (1- (point)))) |
3057 (setq inv-prop (get-text-property pos1 'invisible)) | |
3058 (setq org-inv-prop (get-text-property pos1 'org-invisible)) | |
3059 (cond ((eq inv-prop t) | |
3060 ;; do nothing | |
3061 ) | |
3062 ((eq org-inv-prop nil) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3063 (add-text-properties pos1 pos2 |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3064 (list 'invisible (list t) |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3065 'org-invisible inv-prop))) |
65468 | 3066 (t |
3067 ;; toggle | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3068 (add-text-properties pos1 pos2 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3069 (list 'invisible org-inv-prop)) |
65468 | 3070 (remove-text-properties pos1 pos2 '(org-invisible)))))) |
3071 (newsticker--buffer-redraw)) | |
3072 | |
3073 (defun newsticker-show-entry () | |
3074 "Show description of entry at point." | |
3075 (interactive) | |
3076 (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
|
3077 (let* (pos1 pos2 |
65468 | 3078 (inhibit-read-only t) |
3079 inv-prop org-inv-prop | |
3080 is-invisible) | |
3081 (newsticker--buffer-beginning-of-item) | |
3082 (newsticker--buffer-goto '(desc)) | |
3083 (setq pos1 (max (point-min) (1- (point)))) | |
3084 (newsticker--buffer-goto '(extra feed item)) | |
3085 (setq pos2 (max (point-min) (1- (point)))) | |
3086 (setq inv-prop (get-text-property pos1 'invisible)) | |
3087 (setq org-inv-prop (get-text-property pos1 'org-invisible)) | |
3088 (cond ((eq org-inv-prop nil) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3089 (add-text-properties pos1 pos2 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3090 (list 'invisible nil |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3091 'org-invisible inv-prop))) |
65468 | 3092 (t |
3093 ;; toggle | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3094 (add-text-properties pos1 pos2 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3095 (list 'invisible org-inv-prop)) |
65468 | 3096 (remove-text-properties pos1 pos2 '(org-invisible)))))) |
3097 (newsticker--buffer-redraw)) | |
3098 | |
3099 (defun newsticker-toggle-auto-narrow-to-feed () | |
3100 "Toggle narrowing to current news feed. | |
3101 If auto-narrowing is active, only news item of the current feed | |
3102 are visible." | |
3103 (interactive) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3104 (newsticker-set-auto-narrow-to-feed |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3105 (not newsticker--auto-narrow-to-feed))) |
65468 | 3106 |
3107 (defun newsticker-set-auto-narrow-to-feed (value) | |
3108 "Turn narrowing to current news feed on or off. | |
3109 If VALUE is nil, auto-narrowing is turned off, otherwise it is turned on." | |
3110 (interactive) | |
3111 (setq newsticker--auto-narrow-to-item nil) | |
3112 (setq newsticker--auto-narrow-to-feed value) | |
3113 (widen) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3114 (newsticker--buffer-make-item-completely-visible) |
65468 | 3115 (run-hooks 'newsticker-narrow-hook)) |
3116 | |
3117 (defun newsticker-toggle-auto-narrow-to-item () | |
3118 "Toggle narrowing to current news item. | |
3119 If auto-narrowing is active, only one item of the current feed | |
3120 is visible." | |
3121 (interactive) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3122 (newsticker-set-auto-narrow-to-item |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3123 (not newsticker--auto-narrow-to-item))) |
65468 | 3124 |
3125 (defun newsticker-set-auto-narrow-to-item (value) | |
3126 "Turn narrowing to current news item on or off. | |
3127 If VALUE is nil, auto-narrowing is turned off, otherwise it is turned on." | |
3128 (interactive) | |
3129 (setq newsticker--auto-narrow-to-feed nil) | |
3130 (setq newsticker--auto-narrow-to-item value) | |
3131 (widen) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3132 (newsticker--buffer-make-item-completely-visible) |
65468 | 3133 (run-hooks 'newsticker-narrow-hook)) |
3134 | |
3135 (defun newsticker-customize () | |
3136 "Open the newsticker customization group." | |
3137 (interactive) | |
3138 (customize-group "newsticker")) | |
3139 | |
3140 (defun newsticker-next-feed-available-p () | |
3141 "Return t if position is before last feed, nil otherwise." | |
3142 (save-excursion | |
3143 (let ((p (point))) | |
3144 (newsticker--buffer-goto '(feed)) | |
3145 (not (= p (point)))))) | |
3146 | |
3147 (defun newsticker-previous-feed-available-p () | |
3148 "Return t if position is behind first feed, nil otherwise." | |
3149 (save-excursion | |
3150 (let ((p (point))) | |
3151 (newsticker--buffer-goto '(feed) nil t) | |
3152 (not (= p (point)))))) | |
3153 | |
3154 (defun newsticker-next-item-available-p () | |
3155 "Return t if position is before last feed, nil otherwise." | |
3156 (save-excursion | |
3157 (catch 'result | |
3158 (while (< (point) (point-max)) | |
3159 (unless (newsticker--buffer-goto '(item)) | |
3160 (throw 'result nil)) | |
3161 (unless (newsticker--lists-intersect-p | |
3162 (get-text-property (point) 'invisible) | |
3163 buffer-invisibility-spec) | |
3164 (throw 'result t)))))) | |
3165 | |
3166 (defun newsticker-previous-item-available-p () | |
3167 "Return t if position is behind first item, nil otherwise." | |
3168 (save-excursion | |
3169 (catch 'result | |
3170 (while (> (point) (point-min)) | |
3171 (unless (newsticker--buffer-goto '(item) nil t) | |
3172 (throw 'result nil)) | |
3173 (unless (newsticker--lists-intersect-p | |
3174 (get-text-property (point) 'invisible) | |
3175 buffer-invisibility-spec) | |
3176 (throw 'result t)))))) | |
3177 | |
3178 (defun newsticker-item-not-old-p () | |
3179 "Return t if there is an item at point which is not old, nil otherwise." | |
3180 (when (get-text-property (point) 'feed) | |
3181 (save-excursion | |
3182 (newsticker--buffer-beginning-of-item) | |
3183 (let ((age (get-text-property (point) 'nt-age))) | |
3184 (and (memq age '(new immortal obsolete)) t))))) | |
3185 | |
3186 (defun newsticker-item-not-immortal-p () | |
3187 "Return t if there is an item at point which is not immortal, nil otherwise." | |
3188 (when (get-text-property (point) 'feed) | |
3189 (save-excursion | |
3190 (newsticker--buffer-beginning-of-item) | |
3191 (let ((age (get-text-property (point) 'nt-age))) | |
3192 (and (memq age '(new old obsolete)) t))))) | |
3193 | |
3194 ;; ====================================================================== | |
3195 ;;; local stuff | |
3196 ;; ====================================================================== | |
3197 (defun newsticker-get-news (feed-name) | |
3198 "Get news from the site FEED-NAME and load feed logo. | |
3199 FEED-NAME must be a string which occurs as the label (i.e. the first element) | |
3200 in an element of `newsticker-url-list' or `newsticker-url-list-defaults'." | |
3201 (newsticker--debug-msg "%s: Getting news for %s" | |
3202 (format-time-string "%A, %H:%M" (current-time)) | |
3203 feed-name) | |
3204 (let* ((buffername (concat " *newsticker-wget-" feed-name "*")) | |
3205 (item (or (assoc feed-name newsticker-url-list) | |
3206 (assoc feed-name newsticker-url-list-defaults) | |
3207 (error | |
3208 "Cannot get news for %s: Check newsticker-url-list" | |
3209 feed-name))) | |
3210 (url (cadr item)) | |
3211 (wget-arguments (or (car (cdr (cdr (cdr (cdr item))))) | |
3212 newsticker-wget-arguments))) | |
3213 (save-excursion | |
3214 (set-buffer (get-buffer-create buffername)) | |
3215 (erase-buffer) | |
3216 ;; throw an error if there is an old wget-process around | |
3217 (if (get-process feed-name) | |
3218 (error "Another wget-process is running for %s" feed-name)) | |
3219 ;; start wget | |
3220 (let* ((args (append wget-arguments (list url))) | |
3221 (proc (apply 'start-process feed-name buffername | |
3222 newsticker-wget-name args))) | |
3223 (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
|
3224 (set-process-sentinel proc 'newsticker--sentinel) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3225 (setq newsticker--process-ids (cons (process-id proc) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3226 newsticker--process-ids)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3227 (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
|
3228 |
65468 | 3229 (defun newsticker-mouse-browse-url (event) |
3230 "Call `browse-url' for the link of the item at which the EVENT occurred." | |
3231 (interactive "e") | |
3232 (save-excursion | |
3233 (switch-to-buffer (window-buffer (posn-window (event-end event)))) | |
3234 (let ((url (get-text-property (posn-point (event-end event)) | |
3235 'nt-link))) | |
3236 (when url | |
3237 (browse-url url) | |
3238 (save-excursion | |
3239 (goto-char (posn-point (event-end event))) | |
3240 (if newsticker-automatically-mark-visited-items-as-old | |
3241 (newsticker-mark-item-at-point-as-read t))))))) | |
3242 | |
3243 (defun newsticker-browse-url () | |
3244 "Call `browse-url' for the link of the item at point." | |
3245 (interactive) | |
3246 (let ((url (get-text-property (point) 'nt-link))) | |
3247 (when url | |
3248 (browse-url url) | |
3249 (if newsticker-automatically-mark-visited-items-as-old | |
3250 (newsticker-mark-item-at-point-as-read t))))) | |
3251 | |
3252 (defvar newsticker-open-url-history | |
3253 '("wget" "xmms" "realplay") | |
3254 "...") | |
3255 | |
3256 (defun newsticker-handle-url () | |
3257 "Ask for a program to open the link of the item at point." | |
3258 (interactive) | |
3259 (let ((url (get-text-property (point) 'nt-link))) | |
3260 (when url | |
3261 (let ((prog (read-string "Open url with: " nil | |
3262 'newsticker-open-url-history))) | |
3263 (when prog | |
3264 (message "%s %s" prog url) | |
3265 (start-process prog prog prog url) | |
3266 (if newsticker-automatically-mark-visited-items-as-old | |
3267 (newsticker-mark-item-at-point-as-read t))))))) | |
3268 | |
3269 (defun newsticker--sentinel (process event) | |
3270 "Sentinel for extracting news titles from an RDF buffer. | |
3271 Argument PROCESS is the process which has just changed its state. | |
3272 Argument EVENT tells what has happened to the process." | |
3273 (let* ((p-status (process-status process)) | |
3274 (exit-status (process-exit-status process)) | |
3275 (time (current-time)) | |
3276 (name (process-name process)) | |
3277 (name-symbol (intern name)) | |
3278 (something-was-added nil)) | |
3279 ;; catch known errors (zombie processes, rubbish-xml etc. | |
3280 ;; if an error occurs the news feed is not updated! | |
3281 (catch 'oops | |
3282 (unless (and (eq p-status 'exit) | |
3283 (= exit-status 0)) | |
3284 (setq newsticker--cache | |
3285 (newsticker--cache-add | |
3286 newsticker--cache | |
3287 name-symbol | |
3288 newsticker--error-headline | |
3289 (format | |
3290 (concat "%s: Newsticker could not retrieve news from %s.\n" | |
3291 "Return status: `%s'\n" | |
3292 "Command was `%s'") | |
3293 (format-time-string "%A, %H:%M" (current-time)) | |
3294 name event (process-command process)) | |
3295 "" | |
3296 (current-time) | |
3297 'new | |
3298 0 nil)) | |
3299 (message "%s: Error while retrieving news from %s" | |
3300 (format-time-string "%A, %H:%M" (current-time)) | |
3301 (process-name process)) | |
3302 (throw 'oops nil)) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3303 (let* ((coding-system 'utf-8) |
65468 | 3304 (node-list |
3305 (save-current-buffer | |
3306 (set-buffer (process-buffer process)) | |
3307 ;; a very very dirty workaround to overcome the | |
3308 ;; problems with the newest (20030621) xml.el: | |
3309 ;; remove all unnecessary whitespace | |
3310 (goto-char (point-min)) | |
3311 (while (re-search-forward ">[ \t\r\n]+<" nil t) | |
3312 (replace-match "><" nil t)) | |
3313 ;; and another brutal workaround (20031105)! For some | |
3314 ;; reason the xml parser does not like the colon in the | |
3315 ;; doctype name "rdf:RDF" | |
3316 (goto-char (point-min)) | |
3317 (if (re-search-forward "<!DOCTYPE[ \t\n]+rdf:RDF" nil t) | |
3318 (replace-match "<!DOCTYPE rdfColonRDF" nil t)) | |
3319 ;; finally.... ~##^°!!!!! | |
3320 (goto-char (point-min)) | |
3321 (while (search-forward "\r\n" nil t) | |
3322 (replace-match "\n" nil t)) | |
3323 ;; still more brutal workarounds (20040309)! The xml | |
3324 ;; parser does not like doctype rss | |
3325 (goto-char (point-min)) | |
3326 (if (re-search-forward "<!DOCTYPE[ \t\n]+rss[ \t\n]*>" nil t) | |
3327 (replace-match "" nil t)) | |
3328 ;; And another one (20050618)! (Fixed in GNU Emacs 22.0.50.18) | |
3329 ;; Remove comments to avoid this xml-parsing bug: | |
3330 ;; "XML files can have only one toplevel tag" | |
3331 (goto-char (point-min)) | |
3332 (while (search-forward "<!--" nil t) | |
3333 (let ((start (match-beginning 0))) | |
3334 (unless (search-forward "-->" nil t) | |
3335 (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
|
3336 (delete-region start (point)))) |
65468 | 3337 ;; And another one (20050702)! If description is HTML |
3338 ;; encoded and starts with a `<', wrap the whole | |
3339 ;; description in a CDATA expression. This happened for | |
3340 ;; 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
|
3341 (goto-char (point-min)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3342 (while (re-search-forward |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3343 "<description>\\(<img.*?\\)</description>" nil t) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3344 (replace-match |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3345 "<description><![CDATA[ \\1 ]]></description>")) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3346 ;; 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
|
3347 ;; <yweather:location city="Frankfurt/Main" region="" country="GM" /> |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3348 ;; try to "fix" empty attributes |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3349 ;; This happened for |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3350 ;; 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
|
3351 (goto-char (point-min)) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3352 (while (re-search-forward "\\(<[^>]*\\)=\"\"" nil t) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
3353 (replace-match "\\1=\" \"")) |
65468 | 3354 ;; |
3355 (set-buffer-modified-p nil) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3356 ;; check coding system |
65468 | 3357 (goto-char (point-min)) |
3358 (if (re-search-forward "encoding=\"\\([^\"]+\\)\"" | |
3359 nil t) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3360 (setq coding-system (intern (downcase (match-string 1)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3361 (setq coding-system |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3362 (condition-case nil |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3363 (check-coding-system coding-system) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3364 (coding-system-error |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3365 (message |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3366 "newsticker.el: ignoring coding system %s for %s" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3367 coding-system name) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3368 nil)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3369 ;; Decode if possible |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3370 (when coding-system |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3371 (decode-coding-region (point-min) (point-max) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3372 coding-system)) |
65468 | 3373 (condition-case errordata |
3374 ;; The xml parser might fail | |
3375 ;; or the xml might be bugged | |
3376 (xml-parse-region (point-min) (point-max)) | |
3377 (error (message "Could not parse %s: %s" | |
3378 (buffer-name) (cadr errordata)) | |
3379 (throw 'oops nil))))) | |
3380 (topnode (car node-list)) | |
3381 (channelnode (car (xml-get-children topnode 'channel))) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3382 (imageurl nil)) |
65468 | 3383 ;; mark all items as obsolete |
3384 (newsticker--cache-replace-age newsticker--cache | |
3385 name-symbol | |
3386 'new 'obsolete-new) | |
3387 (newsticker--cache-replace-age newsticker--cache | |
3388 name-symbol | |
3389 'old 'obsolete-old) | |
3390 (newsticker--cache-replace-age newsticker--cache | |
3391 name-symbol | |
3392 'feed 'obsolete-old) | |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
3393 |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3394 ;; check Atom/RSS version and call corresponding parser |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3395 (condition-case error-data |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3396 (if (cond |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3397 ;; RSS 0.91 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3398 ((and (eq 'rss (xml-node-name topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3399 (string= "0.91" (xml-get-attribute topnode 'version))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3400 (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
|
3401 (newsticker--parse-rss-0.91 name time topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3402 ;; RSS 0.92 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3403 ((and (eq 'rss (xml-node-name topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3404 (string= "0.92" (xml-get-attribute topnode 'version))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3405 (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
|
3406 (newsticker--parse-rss-0.92 name time topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3407 ;; RSS 1.0 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3408 ((eq 'rdf:RDF (xml-node-name topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3409 (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
|
3410 (newsticker--parse-rss-1.0 name time topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3411 ;; RSS 2.0 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3412 ((and (eq 'rss (xml-node-name topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3413 (string= "2.0" (xml-get-attribute topnode 'version))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3414 (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
|
3415 (newsticker--parse-rss-2.0 name time topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3416 ;; Atom 0.3 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3417 ((and (eq 'feed (xml-node-name topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3418 (string= "http://purl.org/atom/ns#" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3419 (xml-get-attribute topnode 'xmlns))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3420 (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
|
3421 (newsticker--parse-atom-0.3 name time topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3422 ;; Atom 1.0 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3423 ((and (eq 'feed (xml-node-name topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3424 (string= "http://www.w3.org/2005/Atom" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3425 (xml-get-attribute topnode 'xmlns))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3426 (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
|
3427 (newsticker--parse-atom-1.0 name time topnode)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3428 ;; unknown feed type |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3429 (t |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3430 (newsticker--debug-msg "Feed type unknown: %s: %s" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3431 (xml-node-name topnode) name) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3432 nil)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3433 (setq something-was-added t)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3434 (xerror (message "sentinelerror in %s: %s" name error-data))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3435 |
65468 | 3436 ;; Remove those old items from cache which have been removed from |
3437 ;; the feed | |
3438 (newsticker--cache-replace-age newsticker--cache | |
3439 name-symbol 'obsolete-old 'deleteme) | |
3440 (newsticker--cache-remove newsticker--cache name-symbol | |
3441 'deleteme) | |
3442 ;; Remove those new items from cache which have been removed from | |
3443 ;; the feed. Or keep them as `obsolete' | |
3444 (if (not newsticker-keep-obsolete-items) | |
3445 (newsticker--cache-remove newsticker--cache | |
3446 name-symbol 'obsolete-new) | |
3447 (setq newsticker--cache | |
3448 (newsticker--cache-mark-expired | |
3449 newsticker--cache name-symbol 'obsolete 'obsolete-expired | |
3450 newsticker-obsolete-item-max-age)) | |
3451 (newsticker--cache-remove newsticker--cache | |
3452 name-symbol 'obsolete-expired) | |
3453 (newsticker--cache-replace-age newsticker--cache | |
3454 name-symbol 'obsolete-new | |
3455 'obsolete)) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3456 (newsticker--update-process-ids) |
65468 | 3457 ;; setup scrollable text |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3458 (when (= 0 (length newsticker--process-ids)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3459 (newsticker--ticker-text-setup)) |
65468 | 3460 (setq newsticker--latest-update-time (current-time)) |
3461 (when something-was-added | |
3462 ;; FIXME: should we care about removed items as well? | |
3463 (newsticker--cache-update) | |
3464 (newsticker--buffer-set-uptodate nil)) | |
3465 ;; kill the process buffer if wanted | |
3466 (unless newsticker-debug | |
3467 (kill-buffer (process-buffer process))) | |
3468 ;; launch retrieval of image | |
3469 (when (and imageurl | |
3470 (string-match "%l" newsticker-heading-format)) | |
3471 (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
|
3472 |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3473 (defun newsticker--get-logo-url-atom-1.0 (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3474 "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
|
3475 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3476 (car (xml-get-children node 'logo))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3477 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3478 (defun newsticker--get-logo-url-atom-0.3 (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3479 "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
|
3480 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3481 (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
|
3482 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3483 (defun newsticker--get-logo-url-rss-2.0 (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3484 "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
|
3485 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3486 (car (xml-get-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 node 'channel)) 'image)) 'url))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3489 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3490 (defun newsticker--get-logo-url-rss-1.0 (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3491 "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
|
3492 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3493 (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
|
3494 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3495 (defun newsticker--get-logo-url-rss-0.92 (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3496 "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
|
3497 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3498 (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
|
3499 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3500 (defun newsticker--get-logo-url-rss-0.91 (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3501 "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
|
3502 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3503 (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
|
3504 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3505 (defun newsticker--parse-atom-0.3 (name time topnode) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3506 "Parse Atom 0.3 data. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3507 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
|
3508 same as in `newsticker--parse-atom-1.0'." |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3509 (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
|
3510 (let (new-feed new-item) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3511 (setq new-feed (newsticker--parse-generic-feed |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3512 name time |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3513 ;; title |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3514 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3515 (car (xml-get-children topnode 'title)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3516 ;; desc |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3517 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3518 (car (xml-get-children topnode 'content)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3519 ;; link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3520 (xml-get-attribute |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3521 (car (xml-get-children topnode 'link)) 'href) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3522 ;; extra-elements |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3523 (xml-node-children topnode))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3524 (setq new-item (newsticker--parse-generic-items |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3525 name time (xml-get-children topnode 'entry) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3526 ;; title-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3527 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3528 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3529 (car (xml-get-children node 'title))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3530 ;; desc-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3531 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3532 (or (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3533 (car (xml-get-children node 'content)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3534 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3535 (car (xml-get-children node 'summary)))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3536 ;; link-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3537 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3538 (xml-get-attribute |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3539 (car (xml-get-children node 'link)) 'href)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3540 ;; time-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3541 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3542 (newsticker--decode-rfc822-date |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3543 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3544 (car (xml-get-children node 'modified)))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3545 ;; guid-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3546 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3547 (let ((tguid (assoc 'guid (xml-node-children node)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3548 (if (stringp tguid) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3549 tguid |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3550 (car (xml-node-children tguid))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3551 ;; extra-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3552 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3553 (xml-node-children node)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3554 (or new-item new-feed))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3555 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3556 (defun newsticker--parse-atom-1.0 (name time topnode) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3557 "Parse Atom 1.0 data. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3558 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
|
3559 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
|
3560 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
|
3561 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3562 For the Atom 1.0 specification see |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3563 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
|
3564 (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
|
3565 (let (new-feed new-item) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3566 (setq new-feed (newsticker--parse-generic-feed |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3567 name time |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3568 ;; title |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3569 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3570 (car (xml-get-children topnode 'title)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3571 ;; desc |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3572 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3573 (car (xml-get-children topnode 'subtitle)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3574 ;; link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3575 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3576 (car (xml-get-children topnode 'link)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3577 ;; extra-elements |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3578 (xml-node-children topnode))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3579 (setq new-item (newsticker--parse-generic-items |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3580 name time (xml-get-children topnode 'entry) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3581 ;; title-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3582 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3583 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3584 (car (xml-get-children node 'title))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3585 ;; desc-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3586 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3587 (or (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3588 (car (xml-get-children node 'content)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3589 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3590 (car (xml-get-children node 'summary)))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3591 ;; link-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3592 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3593 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3594 (car (xml-get-children node 'link))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3595 ;; time-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3596 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3597 (newsticker--decode-iso8601-date |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3598 (or (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3599 (car (xml-get-children node 'updated)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3600 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3601 (car (xml-get-children node 'published))))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3602 ;; guid-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3603 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3604 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3605 (car (xml-get-children node 'id))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3606 ;; extra-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3607 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3608 (xml-node-children node)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3609 (or new-item new-feed))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3610 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3611 (defun newsticker--parse-rss-0.91 (name time topnode) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3612 "Parse RSS 0.91 data. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3613 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
|
3614 same as in `newsticker--parse-atom-1.0'. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3615 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3616 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
|
3617 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
|
3618 (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
|
3619 (let* ((channelnode (car (xml-get-children topnode 'channel))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3620 (pub-date (newsticker--decode-rfc822-date |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3621 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3622 (car (xml-get-children channelnode 'pubDate)))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3623 is-new-feed has-new-items) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3624 (setq is-new-feed (newsticker--parse-generic-feed |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3625 name time |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3626 ;; title |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3627 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3628 (car (xml-get-children channelnode 'title)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3629 ;; desc |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3630 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3631 (car (xml-get-children channelnode |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3632 'description)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3633 ;; link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3634 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3635 (car (xml-get-children channelnode 'link)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3636 ;; extra-elements |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3637 (xml-node-children channelnode))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3638 (setq has-new-items (newsticker--parse-generic-items |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3639 name time (xml-get-children channelnode 'item) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3640 ;; title-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3641 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3642 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3643 (car (xml-get-children node 'title))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3644 ;; desc-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3645 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3646 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3647 (car (xml-get-children node 'description))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3648 ;; link-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3649 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3650 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3651 (car (xml-get-children node 'link))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3652 ;; time-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3653 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3654 pub-date) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3655 ;; guid-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3656 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3657 nil) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3658 ;; extra-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3659 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3660 (xml-node-children node)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3661 (or has-new-items is-new-feed))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3662 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3663 (defun newsticker--parse-rss-0.92 (name time topnode) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3664 "Parse RSS 0.92 data. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3665 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
|
3666 same as in `newsticker--parse-atom-1.0'. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3667 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3668 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
|
3669 (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
|
3670 (let* ((channelnode (car (xml-get-children topnode 'channel))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3671 (pub-date (newsticker--decode-rfc822-date |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3672 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3673 (car (xml-get-children channelnode 'pubDate)))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3674 is-new-feed has-new-items) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3675 (setq is-new-feed (newsticker--parse-generic-feed |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3676 name time |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3677 ;; title |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3678 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3679 (car (xml-get-children channelnode 'title)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3680 ;; desc |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3681 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3682 (car (xml-get-children channelnode |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3683 'description)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3684 ;; link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3685 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3686 (car (xml-get-children channelnode 'link)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3687 ;; extra-elements |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3688 (xml-node-children channelnode))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3689 (setq has-new-items (newsticker--parse-generic-items |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3690 name time (xml-get-children channelnode 'item) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3691 ;; title-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3692 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3693 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3694 (car (xml-get-children node 'title))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3695 ;; desc-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3696 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3697 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3698 (car (xml-get-children node 'description))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3699 ;; link-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3700 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3701 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3702 (car (xml-get-children node 'link))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3703 ;; time-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3704 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3705 pub-date) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3706 ;; guid-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3707 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3708 nil) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3709 ;; extra-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3710 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3711 (xml-node-children node)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3712 (or has-new-items is-new-feed))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3713 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3714 (defun newsticker--parse-rss-1.0 (name time topnode) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3715 "Parse RSS 1.0 data. |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
3716 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
|
3717 same as in `newsticker--parse-atom-1.0'. |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3718 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3719 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
|
3720 (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
|
3721 (let* ((channelnode (car (xml-get-children topnode 'channel))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3722 is-new-feed has-new-items) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3723 (setq is-new-feed (newsticker--parse-generic-feed |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3724 name time |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3725 ;; title |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3726 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3727 (car (xml-get-children channelnode 'title)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3728 ;; desc |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3729 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3730 (car (xml-get-children channelnode |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3731 'description)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3732 ;; link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3733 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3734 (car (xml-get-children channelnode 'link)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3735 ;; extra-elements |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3736 (xml-node-children channelnode))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3737 (setq has-new-items (newsticker--parse-generic-items |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3738 name time (xml-get-children topnode 'item) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3739 ;; title-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3740 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3741 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3742 (car (xml-get-children node 'title))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3743 ;; desc-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3744 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3745 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3746 (car (xml-get-children node |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3747 'description))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3748 ;; link-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3749 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3750 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3751 (car (xml-get-children node 'link))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3752 ;; time-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3753 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3754 (newsticker--decode-iso8601-date |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3755 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3756 (car (xml-get-children node 'dc:date)))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3757 ;; guid-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3758 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3759 nil) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3760 ;; extra-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3761 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3762 (xml-node-children node)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3763 (or has-new-items is-new-feed))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3764 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3765 (defun newsticker--parse-rss-2.0 (name time topnode) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3766 "Parse RSS 2.0 data. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3767 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
|
3768 same as in `newsticker--parse-atom-1.0'. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3769 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3770 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
|
3771 (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
|
3772 (let* ((channelnode (car (xml-get-children topnode 'channel))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3773 is-new-feed has-new-items) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3774 (setq is-new-feed (newsticker--parse-generic-feed |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3775 name time |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3776 ;; title |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3777 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3778 (car (xml-get-children channelnode 'title)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3779 ;; desc |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3780 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3781 (car (xml-get-children channelnode |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3782 'description)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3783 ;; link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3784 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3785 (car (xml-get-children channelnode 'link)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3786 ;; extra-elements |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3787 (xml-node-children channelnode))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3788 (setq has-new-items (newsticker--parse-generic-items |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3789 name time (xml-get-children channelnode 'item) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3790 ;; title-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3791 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3792 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3793 (car (xml-get-children node 'title))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3794 ;; desc-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3795 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3796 (or (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3797 (car (xml-get-children node |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3798 'content:encoded)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3799 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3800 (car (xml-get-children node |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3801 'description)))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3802 ;; link-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3803 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3804 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3805 (car (xml-get-children node 'link))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3806 ;; time-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3807 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3808 (newsticker--decode-rfc822-date |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3809 (car (xml-node-children |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3810 (car (xml-get-children node 'pubDate)))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3811 ;; guid-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3812 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3813 (let* ((tguid (assoc 'guid |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3814 (xml-node-children node)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3815 (if (stringp tguid) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3816 tguid |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3817 (car (xml-node-children tguid))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3818 ;; extra-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3819 (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3820 (xml-node-children node)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3821 (or has-new-items is-new-feed))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3822 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3823 (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
|
3824 extra-elements) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3825 "Parse generic news feed data. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3826 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
|
3827 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
|
3828 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3829 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
|
3830 description, link, and extra elements resp." |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3831 (let ((title (or title "[untitled]")) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3832 (link (or link "")) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3833 (old-item nil) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3834 (position 0) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3835 (something-was-added nil)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3836 ;; decode numeric entities |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3837 (setq title (newsticker--decode-numeric-entities title)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3838 (setq desc (newsticker--decode-numeric-entities desc)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3839 (setq link (newsticker--decode-numeric-entities link)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3840 ;; remove whitespace from title, desc, and link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3841 (setq title (newsticker--remove-whitespace title)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3842 (setq desc (newsticker--remove-whitespace desc)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3843 (setq link (newsticker--remove-whitespace link)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3844 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3845 ;; handle the feed itself |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3846 (unless (newsticker--cache-contains newsticker--cache |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3847 (intern name) title |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3848 desc link 'feed) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3849 (setq something-was-added t)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3850 (setq newsticker--cache |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3851 (newsticker--cache-add newsticker--cache (intern name) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3852 title desc link time 'feed position |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3853 extra-elements 'feed time)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3854 something-was-added)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3855 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3856 (defun newsticker--parse-generic-items (name time itemlist |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3857 title-fn desc-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3858 link-fn time-fn |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3859 guid-fn extra-fn) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3860 "Parse generic news feed data. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3861 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
|
3862 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
|
3863 contains the news items returned by the xml parser. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3864 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3865 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
|
3866 EXTRA-FN give functions for extracting title, description, link, |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3867 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
|
3868 argument, which is one of the items in ITEMLIST." |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3869 (let (title desc link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3870 (old-item nil) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3871 (position 0) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3872 (something-was-added nil)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3873 ;; gather all items for this feed |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3874 (mapc (lambda (node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3875 (setq position (1+ position)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3876 (setq title (or (funcall title-fn node) "[untitled]")) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3877 (setq desc (funcall desc-fn node)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3878 (setq link (or (funcall link-fn node) "")) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3879 (setq time (or (funcall time-fn node) time)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3880 ;; It happened that the title or description |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3881 ;; contained evil HTML code that confused the |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3882 ;; xml parser. Therefore: |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3883 (unless (stringp title) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3884 (setq title (prin1-to-string title))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3885 (unless (or (stringp desc) (not desc)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3886 (setq desc (prin1-to-string desc))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3887 ;; ignore items with empty title AND empty desc |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3888 (when (or (> (length title) 0) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3889 (> (length desc) 0)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3890 ;; decode numeric entities |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3891 (setq title (newsticker--decode-numeric-entities title)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3892 (when desc |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3893 (setq desc (newsticker--decode-numeric-entities desc))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3894 (setq link (newsticker--decode-numeric-entities link)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3895 ;; remove whitespace from title, desc, and link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3896 (setq title (newsticker--remove-whitespace title)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3897 (setq desc (newsticker--remove-whitespace desc)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3898 (setq link (newsticker--remove-whitespace link)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3899 ;; add data to cache |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3900 ;; do we have this item already? |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3901 (let* ((guid (funcall guid-fn node))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3902 ;;(message "guid=%s" guid) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3903 (setq old-item |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3904 (newsticker--cache-contains newsticker--cache |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3905 (intern name) title |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3906 desc link nil guid))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3907 ;; 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
|
3908 (let ((age1 'new) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3909 (age2 'old) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3910 (item-new-p nil)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3911 (if old-item |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3912 (let ((prev-age (newsticker--age old-item))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3913 (unless |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3914 newsticker-automatically-mark-items-as-old |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3915 (if (eq prev-age 'obsolete-old) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3916 (setq age2 'old) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3917 (setq age2 'new))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3918 (if (eq prev-age 'immortal) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3919 (setq age2 'immortal))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3920 ;; item was not there |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3921 (setq item-new-p t) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3922 (setq something-was-added t)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3923 (setq newsticker--cache |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3924 (newsticker--cache-add |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3925 newsticker--cache (intern name) title desc link |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3926 time age1 position (funcall extra-fn node) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3927 age2)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3928 (when item-new-p |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3929 (let ((item (newsticker--cache-contains |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3930 newsticker--cache (intern name) title |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3931 desc link nil))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3932 (if newsticker-auto-mark-filter-list |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3933 (newsticker--run-auto-mark-filter name item)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3934 (run-hook-with-args |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3935 'newsticker-new-item-functions name item)))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3936 itemlist) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3937 something-was-added)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
3938 |
65468 | 3939 (defun newsticker--display-tick () |
3940 "Called from the display timer. | |
3941 This function calls a display function, according to the variable | |
3942 `newsticker-scroll-smoothly'." | |
3943 (if newsticker-scroll-smoothly | |
3944 (newsticker--display-scroll) | |
3945 (newsticker--display-jump))) | |
3946 | |
3947 (defsubst newsticker--echo-area-clean-p () | |
3948 "Check whether somebody is using the echo area / minibuffer. | |
3949 Return t if echo area and minibuffer are unused." | |
3950 (not (or (active-minibuffer-window) | |
3951 (and (current-message) | |
3952 (not (string= (current-message) | |
3953 newsticker--prev-message)))))) | |
3954 | |
3955 (defun newsticker--display-jump () | |
3956 "Called from the display timer. | |
3957 This function displays the next ticker item in the echo area, unless | |
3958 there is another message displayed or the minibuffer is active." | |
3959 (let ((message-log-max nil));; prevents message text from being logged | |
3960 (when (newsticker--echo-area-clean-p) | |
3961 (setq newsticker--item-position (1+ newsticker--item-position)) | |
3962 (when (>= newsticker--item-position (length newsticker--item-list)) | |
3963 (setq newsticker--item-position 0)) | |
3964 (setq newsticker--prev-message | |
3965 (nth newsticker--item-position newsticker--item-list)) | |
65586
86bece058ee5
Message format fixes (commit no. 5)
Deepak Goel <deego@gnufans.org>
parents:
65490
diff
changeset
|
3966 (message "%s" newsticker--prev-message)))) |
65468 | 3967 |
3968 (defun newsticker--display-scroll () | |
3969 "Called from the display timer. | |
3970 This function scrolls the ticker items in the echo area, unless | |
3971 there is another message displayed or the minibuffer is active." | |
3972 (when (newsticker--echo-area-clean-p) | |
3973 (let* ((width (- (frame-width) 1)) | |
3974 (message-log-max nil);; prevents message text from being logged | |
3975 (i newsticker--item-position) | |
3976 subtext | |
3977 (s-text newsticker--scrollable-text) | |
3978 (l (length s-text))) | |
3979 ;; don't show anything if there is nothing to show | |
3980 (unless (< (length s-text) 1) | |
3981 ;; repeat the ticker string if it is shorter than frame width | |
3982 (while (< (length s-text) width) | |
3983 (setq s-text (concat s-text s-text))) | |
3984 ;; get the width of the printed string | |
3985 (setq l (length s-text)) | |
3986 (cond ((< i (- l width)) | |
3987 (setq subtext (substring s-text i (+ i width)))) | |
3988 (t | |
3989 (setq subtext (concat | |
3990 (substring s-text i l) | |
3991 (substring s-text 0 (- width (- l i))))))) | |
3992 ;; Take care of multibyte strings, for which (string-width) is | |
3993 ;; larger than (length). | |
3994 ;; Actually, such strings may be smaller than (frame-width) | |
3995 ;; because return values of (string-width) are too large: | |
3996 ;; (string-width "<japanese character>") => 2 | |
3997 (let ((t-width (1- (length subtext)))) | |
3998 (while (> (string-width subtext) width) | |
3999 (setq subtext (substring subtext 0 t-width)) | |
4000 (setq t-width (1- t-width)))) | |
4001 ;; 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
|
4002 (message "%s" subtext) |
65468 | 4003 (setq newsticker--prev-message subtext) |
4004 (setq newsticker--item-position (1+ i)) | |
4005 (when (>= newsticker--item-position l) | |
4006 (setq newsticker--item-position 0)))))) | |
4007 | |
4008 ;; ====================================================================== | |
4009 ;;; misc | |
4010 ;; ====================================================================== | |
4011 (defun newsticker--decode-numeric-entities (string) | |
4012 "Decode SGML numeric entities by their respective utf characters. | |
4013 This function replaces numeric entities in the input STRING and | |
4014 returns the modified string. For example \"*\" gets replaced | |
4015 by \"*\"." | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4016 (if (and string (stringp string)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4017 (let ((start 0)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4018 (while (string-match "&#\\([0-9]+\\);" string start) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4019 (condition-case nil |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4020 (setq string (replace-match |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4021 (string (read (substring string |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4022 (match-beginning 1) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4023 (match-end 1)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4024 nil nil string)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4025 (error nil)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4026 (setq start (1+ (match-beginning 0)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4027 string) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4028 nil)) |
65468 | 4029 |
4030 (defun newsticker--remove-whitespace (string) | |
4031 "Remove leading and trailing whitespace from STRING." | |
4032 ;; we must have ...+ but not ...* in the regexps otherwise xemacs loops | |
4033 ;; endlessly... | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4034 (when (and string (stringp string)) |
65468 | 4035 (replace-regexp-in-string |
4036 "[ \t\r\n]+$" "" | |
4037 (replace-regexp-in-string "^[ \t\r\n]+" "" string)))) | |
4038 | |
4039 (defun newsticker--do-forget-preformatted (item) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4040 "Forget pre-formatted data for ITEM. |
65468 | 4041 Remove the pre-formatted from `newsticker--cache'." |
4042 (if (nthcdr 7 item) | |
4043 (setcar (nthcdr 7 item) nil)) | |
4044 (if (nthcdr 6 item) | |
4045 (setcar (nthcdr 6 item) nil))) | |
4046 | |
4047 (defun newsticker--forget-preformatted () | |
4048 "Forget all cached pre-formatted data. | |
4049 Remove the pre-formatted from `newsticker--cache'." | |
4050 (mapc (lambda (feed) | |
4051 (mapc 'newsticker--do-forget-preformatted | |
4052 (cdr feed))) | |
4053 newsticker--cache) | |
4054 (newsticker--buffer-set-uptodate nil)) | |
4055 | |
4056 (defun newsticker--debug-msg (string &rest args) | |
4057 "Print newsticker debug messages. | |
4058 This function calls `message' with arguments STRING and ARGS, if | |
4059 `newsticker-debug' is non-nil." | |
4060 (and newsticker-debug | |
4061 ;;(not (active-minibuffer-window)) | |
4062 ;;(not (current-message)) | |
4063 (apply 'message string args))) | |
4064 | |
4065 (defun newsticker--decode-iso8601-date (iso8601-string) | |
4066 "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
|
4067 Converts from ISO-8601 to Emacs representation. |
65468 | 4068 Examples: |
4069 2004-09-17T05:09:49+00:00 | |
4070 2004-09-17T05:09+00:00 | |
4071 2004-09-17T05:09:49 | |
4072 2004-09-17T05:09 | |
4073 2004-09-17 | |
4074 2004-09 | |
4075 2004" | |
4076 (if iso8601-string | |
4077 (when (string-match | |
4078 (concat | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
4079 "^ *\\([0-9]\\{4\\}\\)" |
65468 | 4080 "\\(-\\([0-9]\\{2\\}\\)" |
4081 "\\(-\\([0-9]\\{2\\}\\)" | |
4082 "\\(T" | |
4083 "\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)" | |
4084 "\\(:\\([0-9]\\{2\\}\\)\\)?" | |
4085 "\\(\\([-+Z]\\)\\(\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)?" | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
4086 "\\)?\\)?\\)? *$") |
65468 | 4087 iso8601-string) |
4088 (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
|
4089 (month (read (or (match-string 3 iso8601-string) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
4090 "1"))) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
4091 (day (read (or (match-string 5 iso8601-string) |
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
4092 "1"))) |
65468 | 4093 (hour (read (or (match-string 7 iso8601-string) |
4094 "0"))) | |
4095 (minute (read (or (match-string 8 iso8601-string) | |
4096 "0"))) | |
4097 ;;(second (read (or (match-string 10 iso8601-string) | |
4098 ;; "0"))) | |
4099 (sign (match-string 12 iso8601-string)) | |
4100 (offset-hour (read (or (match-string 14 iso8601-string) | |
4101 "0"))) | |
4102 (offset-minute (read (or (match-string 15 iso8601-string) | |
4103 "0"))) | |
4104 (second 0)) | |
4105 (cond ((string= sign "+") | |
4106 (setq hour (- hour offset-hour)) | |
4107 (setq minute (- minute offset-minute))) | |
4108 ((string= sign "-") | |
4109 (setq hour (+ hour offset-hour)) | |
4110 (setq minute (+ minute offset-minute)))) | |
4111 ;; if UTC subtract current-time-zone offset | |
4112 ;;(setq second (+ (car (current-time-zone)) second))) | |
4113 | |
4114 (condition-case nil | |
4115 (encode-time second minute hour day month year t) | |
4116 (error | |
4117 (message "Cannot decode \"%s\"" iso8601-string) | |
4118 nil)))) | |
4119 nil)) | |
4120 | |
4121 (defun newsticker--decode-rfc822-date (rfc822-string) | |
4122 "Return RFC822-STRING in format like `decode-time'. | |
4123 Converts from RFC822 to Emacs representation. | |
4124 Examples: | |
4125 Sat, 07 Sep 2002 00:00:01 GMT | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4126 07 Sep 2002 00:00:01 GMT |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4127 07 Sep 2002" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4128 (if (and rfc822-string (stringp rfc822-string)) |
65468 | 4129 (when (string-match |
4130 (concat | |
4131 "\\s-*" | |
4132 ;; week day | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4133 "\\(\\(Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\|Sun\\)\\s-*,?\\)?\\s-*" |
65468 | 4134 ;; day |
4135 "\\([0-9]\\{1,2\\}\\)\\s-+" | |
4136 ;; month | |
4137 "\\(Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|Jul\\|Aug\\|" | |
4138 "Sep\\|Oct\\|Nov\\|Dec\\)\\s-+" | |
4139 ;; year | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4140 "\\([0-9]\\{2,4\\}\\)" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4141 ;; time may be missing |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4142 "\\(\\s-+" |
65468 | 4143 ;; hour |
4144 "\\([0-9]\\{2\\}\\)" | |
4145 ;; minute | |
4146 ":\\([0-9]\\{2\\}\\)" | |
4147 ;; second | |
4148 "\\(:\\([0-9]\\{2\\}\\)\\)?" | |
4149 ;; zone -- fixme | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4150 "\\(\\s-+.*\\)?" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4151 "\\)?") |
65468 | 4152 rfc822-string) |
4153 (let ((day (read (match-string 3 rfc822-string))) | |
4154 (month-name (match-string 4 rfc822-string)) | |
4155 (month 0) | |
4156 (year (read (match-string 5 rfc822-string))) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4157 (hour (read (or (match-string 7 rfc822-string) "0"))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4158 (minute (read (or (match-string 8 rfc822-string) "0"))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4159 (second (read (or (match-string 10 rfc822-string) "0"))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4160 ;;(zone (match-string 11 rfc822-string)) |
65468 | 4161 ) |
4162 (condition-case error-data | |
4163 (let ((i 1)) | |
4164 (mapc (lambda (m) | |
4165 (if (string= month-name m) | |
4166 (setq month i)) | |
4167 (setq i (1+ i))) | |
4168 '("Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" | |
4169 "Sep" "Oct" "Nov" "Dec")) | |
4170 (encode-time second minute hour day month year t)) | |
4171 (error | |
4172 (message "Cannot decode \"%s\": %s %s" rfc822-string | |
4173 (car error-data) (cdr error-data)) | |
4174 nil)))) | |
4175 nil)) | |
4176 | |
4177 (defun newsticker--lists-intersect-p (list1 list2) | |
4178 "Return t if LIST1 and LIST2 share elements." | |
4179 (let ((result nil)) | |
4180 (mapc (lambda (elt) | |
4181 (if (memq elt list2) | |
4182 (setq result t))) | |
4183 list1) | |
4184 result)) | |
4185 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4186 (defun newsticker--update-process-ids () |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4187 "Update list of ids of active newsticker processes. |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4188 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
|
4189 (let ((active-procs (process-list)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4190 (new-list nil)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4191 (mapc (lambda (proc) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4192 (let ((id (process-id proc))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4193 (if (memq id newsticker--process-ids) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4194 (setq new-list (cons id new-list))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4195 active-procs) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4196 (setq newsticker--process-ids new-list)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4197 (force-mode-line-update)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4198 |
65468 | 4199 ;; ====================================================================== |
4200 ;;; images | |
4201 ;; ====================================================================== | |
4202 (defun newsticker--image-get (feed-name url) | |
4203 "Get image of the news site FEED-NAME from URL. | |
4204 If the image has been downloaded in the last 24h do nothing." | |
4205 (let ((image-name (concat newsticker-imagecache-dirname "/" | |
4206 feed-name))) | |
4207 (if (and (file-exists-p image-name) | |
4208 (time-less-p (current-time) | |
4209 (time-add (nth 5 (file-attributes image-name)) | |
4210 (seconds-to-time 86400)))) | |
4211 (newsticker--debug-msg "%s: Getting image for %s skipped" | |
4212 (format-time-string "%A, %H:%M" (current-time)) | |
4213 feed-name) | |
4214 ;; download | |
4215 (newsticker--debug-msg "%s: Getting image for %s" | |
4216 (format-time-string "%A, %H:%M" (current-time)) | |
4217 feed-name) | |
4218 (let* ((buffername (concat " *newsticker-wget-image-" feed-name "*")) | |
4219 (item (or (assoc feed-name newsticker-url-list) | |
4220 (assoc feed-name newsticker-url-list-defaults) | |
4221 (error | |
4222 "Cannot get news for %s: Check newsticker-url-list" | |
4223 feed-name))) | |
4224 (wget-arguments (or (car (cdr (cdr (cdr (cdr item))))) | |
4225 newsticker-wget-arguments))) | |
4226 (save-excursion | |
4227 (set-buffer (get-buffer-create buffername)) | |
4228 (erase-buffer) | |
4229 ;; throw an error if there is an old wget-process around | |
4230 (if (get-process feed-name) | |
4231 (error "Another wget-process is running for image %s" | |
4232 feed-name)) | |
4233 ;; start wget | |
4234 (let* ((args (append wget-arguments (list url))) | |
4235 (proc (apply 'start-process feed-name buffername | |
4236 newsticker-wget-name args))) | |
4237 (set-process-coding-system proc 'no-conversion 'no-conversion) | |
4238 (set-process-sentinel proc 'newsticker--image-sentinel))))))) | |
4239 | |
4240 (defun newsticker--image-sentinel (process event) | |
4241 "Sentinel for image-retrieving PROCESS caused by EVENT." | |
4242 (let* ((p-status (process-status process)) | |
4243 (exit-status (process-exit-status process)) | |
4244 (feed-name (process-name process))) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4245 ;; catch known errors (zombie processes, rubbish-xml, etc.) |
65468 | 4246 ;; if an error occurs the news feed is not updated! |
4247 (catch 'oops | |
4248 (unless (and (eq p-status 'exit) | |
4249 (= exit-status 0)) | |
4250 (message "%s: Error while retrieving image from %s" | |
4251 (format-time-string "%A, %H:%M" (current-time)) | |
4252 feed-name) | |
4253 (throw 'oops nil)) | |
4254 (let (image-name) | |
4255 (save-excursion | |
4256 (set-buffer (process-buffer process)) | |
4257 (setq image-name (concat newsticker-imagecache-dirname "/" | |
4258 feed-name)) | |
4259 (set-buffer-file-coding-system 'no-conversion) | |
4260 ;; make sure the cache dir exists | |
4261 (unless (file-directory-p newsticker-imagecache-dirname) | |
4262 (make-directory newsticker-imagecache-dirname)) | |
4263 ;; write and close buffer | |
4264 (let ((require-final-newline nil) | |
4265 (backup-inhibited t) | |
4266 (coding-system-for-write 'no-conversion)) | |
4267 (write-region nil nil image-name nil 'quiet)) | |
4268 (set-buffer-modified-p nil) | |
4269 (kill-buffer (current-buffer))))))) | |
4270 | |
4271 (defun newsticker--image-read (feed-name-symbol disabled) | |
4272 "Read the cached image for FEED-NAME-SYMBOL from disk. | |
4273 If DISABLED is non-nil the image will be converted to a disabled look | |
4274 \(unless `newsticker-enable-logo-manipulations' is not t\). | |
4275 Return the image." | |
4276 (let ((image-name (concat newsticker-imagecache-dirname "/" | |
4277 (symbol-name feed-name-symbol))) | |
4278 (img nil)) | |
4279 (when (file-exists-p image-name) | |
4280 (condition-case error-data | |
4281 (setq img (create-image | |
4282 image-name nil nil | |
4283 :conversion (and newsticker-enable-logo-manipulations | |
4284 disabled | |
4285 'disabled) | |
4286 :mask (and newsticker-enable-logo-manipulations | |
4287 'heuristic) | |
4288 :ascent 70)) | |
4289 (error | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4290 (message "Error: cannot create image for %s: %s" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4291 feed-name-symbol error-data)))) |
65468 | 4292 img)) |
4293 | |
4294 ;; ====================================================================== | |
4295 ;;; imenu stuff | |
4296 ;; ====================================================================== | |
4297 (defun newsticker--imenu-create-index () | |
4298 "Scan newsticker buffer and return an index for imenu." | |
4299 (save-excursion | |
4300 (goto-char (point-min)) | |
4301 (let ((index-alist nil) | |
4302 (feed-list nil) | |
4303 (go-ahead t)) | |
4304 (while go-ahead | |
4305 (let ((type (get-text-property (point) 'nt-type)) | |
4306 (title (get-text-property (point) 'nt-title))) | |
4307 (cond ((eq type 'feed) | |
4308 ;; we're on a feed heading | |
4309 (when feed-list | |
4310 (if index-alist | |
4311 (nconc index-alist (list feed-list)) | |
4312 (setq index-alist (list feed-list)))) | |
4313 (setq feed-list (list title))) | |
4314 (t | |
4315 (nconc feed-list | |
4316 (list (cons title (point))))))) | |
4317 (setq go-ahead (newsticker--buffer-goto '(item feed)))) | |
4318 (if index-alist | |
4319 (nconc index-alist (list feed-list)) | |
4320 (setq index-alist (list feed-list))) | |
4321 index-alist))) | |
4322 | |
4323 (defun newsticker--imenu-goto (name pos &rest args) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4324 "Go to item NAME at position POS and show item. |
65468 | 4325 ARGS are ignored." |
4326 (goto-char pos) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4327 ;; show headline |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4328 (newsticker--buffer-goto '(desc extra feed item)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4329 (let* ((inhibit-read-only t) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4330 (pos1 (max (point-min) (1- pos))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4331 (pos2 (max pos1 (1- (point)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4332 (inv-prop (get-text-property pos 'invisible)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4333 (org-inv-prop (get-text-property pos 'org-invisible))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4334 (when (eq org-inv-prop nil) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4335 (add-text-properties pos1 pos2 (list 'invisible nil |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4336 'org-invisible inv-prop)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4337 ;; show desc |
65468 | 4338 (newsticker-show-entry)) |
4339 | |
4340 ;; ====================================================================== | |
4341 ;;; buffer stuff | |
4342 ;; ====================================================================== | |
4343 (defun newsticker--buffer-set-uptodate (value) | |
4344 "Set the uptodate-status of the newsticker buffer to VALUE. | |
4345 The mode-line is changed accordingly." | |
4346 (setq newsticker--buffer-uptodate-p value) | |
4347 (let ((b (get-buffer "*newsticker*"))) | |
4348 (when b | |
4349 (save-excursion | |
4350 (set-buffer b) | |
4351 (if value | |
4352 (setq mode-name "Newsticker -- up to date -- ") | |
4353 (setq mode-name "Newsticker -- NEED UPDATE -- "))) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4354 (force-mode-line-update 0)))) |
65468 | 4355 |
4356 (defun newsticker--buffer-redraw () | |
75646
56945fba998d
(newsticker--insert-image): Update docstring. Insert the image directly.
Chong Yidong <cyd@stupidchicken.com>
parents:
75606
diff
changeset
|
4357 "Redraw the newsticker window." |
65468 | 4358 (if (fboundp 'force-window-update) |
4359 (force-window-update (current-buffer)) | |
4360 (redraw-frame (selected-frame))) | |
4361 (run-hooks 'newsticker-buffer-change-hook) | |
4362 (sit-for 0)) | |
4363 | |
4364 (defun newsticker--buffer-insert-all-items () | |
4365 "Insert all cached newsticker items into the current buffer. | |
4366 Keeps order of feeds as given in `newsticker-url-list' and | |
4367 `newsticker-url-list-defaults'." | |
4368 (goto-char (point-min)) | |
4369 (mapc (lambda (url-item) | |
4370 (let* ((feed-name (car url-item)) | |
4371 (feed-name-symbol (intern feed-name)) | |
4372 (feed (assoc feed-name-symbol newsticker--cache)) | |
4373 (items (cdr feed)) | |
4374 (pos (point))) | |
4375 (when feed | |
4376 ;; insert the feed description | |
4377 (mapc (lambda (item) | |
4378 (when (eq (newsticker--age item) 'feed) | |
4379 (newsticker--buffer-insert-item item | |
4380 feed-name-symbol))) | |
4381 items) | |
4382 ;;insert the items | |
4383 (mapc (lambda (item) | |
4384 (if (memq (newsticker--age item) '(new immortal old | |
4385 obsolete)) | |
4386 (newsticker--buffer-insert-item item | |
4387 feed-name-symbol))) | |
4388 items) | |
4389 (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
|
4390 |
65468 | 4391 ;; insert empty line between feeds |
4392 (let ((p (point))) | |
4393 (insert "\n") | |
4394 (put-text-property p (point) 'hard t))))) | |
4395 (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
|
4396 |
65468 | 4397 (newsticker--buffer-set-faces (point-min) (point-max)) |
4398 (newsticker--buffer-set-invisibility (point-min) (point-max)) | |
4399 (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
|
4400 |
65468 | 4401 (defun newsticker--buffer-insert-item (item &optional feed-name-symbol) |
4402 "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
|
4403 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
|
4404 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
|
4405 item-retrieval time is added as well." |
65468 | 4406 ;; insert headline |
4407 (if (eq (newsticker--age item) 'feed) | |
4408 (newsticker--buffer-do-insert-text item 'feed feed-name-symbol) | |
4409 (newsticker--buffer-do-insert-text item 'item feed-name-symbol)) | |
4410 ;; insert the description | |
4411 (newsticker--buffer-do-insert-text item 'desc feed-name-symbol)) | |
4412 | |
4413 (defun newsticker--buffer-do-insert-text (item type feed-name-symbol) | |
4414 "Actually insert contents of news item, format it, render it and all that. | |
4415 ITEM is a news item, TYPE tells which part of the item shall be inserted, | |
4416 FEED-NAME-SYMBOL tells to which feed this item belongs." | |
4417 (let* ((pos (point)) | |
4418 (format newsticker-desc-format) | |
4419 (pos-date-start nil) | |
4420 (pos-date-end nil) | |
4421 (pos-stat-start nil) | |
4422 (pos-stat-end nil) | |
4423 (pos-text-start nil) | |
4424 (pos-text-end nil) | |
4425 (pos-extra-start nil) | |
4426 (pos-extra-end nil) | |
4427 (pos-enclosure-start nil) | |
4428 (pos-enclosure-end nil) | |
4429 (age (newsticker--age item)) | |
4430 (preformatted-contents (newsticker--preformatted-contents item)) | |
4431 (preformatted-title (newsticker--preformatted-title item))) | |
4432 (cond ((and preformatted-contents | |
4433 (not (eq (aref preformatted-contents 0) ?\n));; we must | |
4434 ;; NOT have a line | |
4435 ;; break! | |
4436 (eq type 'desc)) | |
4437 (insert preformatted-contents)) | |
4438 ((and preformatted-title | |
4439 (not (eq (aref preformatted-title 0) ?\n));; we must NOT have a | |
4440 ;; line break! | |
4441 (eq type 'item)) | |
4442 (insert preformatted-title)) | |
4443 (t | |
4444 ;; item was not formatted before. | |
4445 ;; Let's go. | |
4446 (if (eq type 'item) | |
4447 (setq format newsticker-item-format) | |
4448 (if (eq type 'feed) | |
4449 (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
|
4450 |
65468 | 4451 (while (> (length format) 0) |
4452 (let ((prefix (if (> (length format) 1) | |
4453 (substring format 0 2) | |
4454 ""))) | |
4455 (cond ((string= "%c" prefix) | |
4456 ;; contents | |
4457 (when (newsticker--desc item) | |
4458 (setq pos-text-start (point-marker)) | |
4459 (insert (newsticker--desc item)) | |
4460 (setq pos-text-end (point-marker))) | |
4461 (setq format (substring format 2))) | |
4462 ((string= "%d" prefix) | |
4463 ;; date | |
4464 (setq pos-date-start (point-marker)) | |
4465 (if (newsticker--time item) | |
4466 (insert (format-time-string newsticker-date-format | |
4467 (newsticker--time item)))) | |
4468 (setq pos-date-end (point-marker)) | |
4469 (setq format (substring format 2))) | |
4470 ((string= "%l" prefix) | |
4471 ;; logo | |
4472 (let ((disabled (cond ((eq (newsticker--age item) 'feed) | |
4473 (= (newsticker--stat-num-items | |
4474 feed-name-symbol 'new) 0)) | |
4475 (t | |
4476 (not (eq (newsticker--age item) | |
4477 'new)))))) | |
4478 (let ((img (newsticker--image-read feed-name-symbol | |
4479 disabled))) | |
4480 (when img | |
4481 (newsticker--insert-image img (car item))))) | |
4482 (setq format (substring format 2))) | |
4483 ((string= "%L" prefix) | |
4484 ;; logo or title | |
4485 (let ((disabled (cond ((eq (newsticker--age item) 'feed) | |
4486 (= (newsticker--stat-num-items | |
4487 feed-name-symbol 'new) 0)) | |
4488 (t | |
4489 (not (eq (newsticker--age item) | |
4490 'new)))))) | |
4491 (let ((img (newsticker--image-read feed-name-symbol | |
4492 disabled))) | |
4493 (if img | |
4494 (newsticker--insert-image img (car item)) | |
4495 (when (car item) | |
4496 (setq pos-text-start (point-marker)) | |
4497 (if (eq (newsticker--age item) 'feed) | |
4498 (insert (newsticker--title item)) | |
4499 ;; FIXME: This is not the "real" title! | |
4500 (insert (format "%s" | |
4501 (car (newsticker--cache-get-feed | |
4502 feed-name-symbol))))) | |
4503 (setq pos-text-end (point-marker)))))) | |
4504 (setq format (substring format 2))) | |
4505 ((string= "%s" prefix) | |
4506 ;; statistics | |
4507 (setq pos-stat-start (point-marker)) | |
4508 (if (eq (newsticker--age item) 'feed) | |
4509 (insert (newsticker--buffer-statistics | |
4510 feed-name-symbol))) | |
4511 (setq pos-stat-end (point-marker)) | |
4512 (setq format (substring format 2))) | |
4513 ((string= "%t" prefix) | |
4514 ;; title | |
4515 (when (car item) | |
4516 (setq pos-text-start (point-marker)) | |
4517 (insert (car item)) | |
4518 (setq pos-text-end (point-marker))) | |
4519 (setq format (substring format 2))) | |
4520 ((string-match "%." prefix) | |
4521 ;; unknown specifier! | |
4522 (insert prefix) | |
4523 (setq format (substring format 2))) | |
4524 ((string-match "^\\([^%]*\\)\\(.*\\)" format) ;; FIXME! | |
4525 ;; everything else | |
4526 (let ((p (point))) | |
4527 (insert (substring format | |
4528 (match-beginning 1) (match-end 1))) | |
4529 ;; in case that the format string contained newlines | |
4530 (put-text-property p (point) 'hard t)) | |
4531 (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
|
4532 |
65468 | 4533 ;; decode HTML if possible... |
4534 (let ((is-rendered-HTML nil)) | |
4535 (when (and newsticker-html-renderer pos-text-start pos-text-end) | |
4536 (condition-case error-data | |
4537 (save-excursion | |
4538 ;; check whether it is necessary to call html renderer | |
4539 ;; (regexp inspired by htmlr.el) | |
4540 (goto-char pos-text-start) | |
4541 (when (re-search-forward | |
4542 "</?[A-Za-z1-6]*\\|&#?[A-Za-z0-9]+;" pos-text-end t) | |
4543 ;; (message "%s" (newsticker--title item)) | |
4544 (let ((w3m-fill-column (if newsticker-use-full-width | |
4545 -1 fill-column)) | |
4546 (w3-maximum-line-length | |
4547 (if newsticker-use-full-width nil fill-column))) | |
4548 (save-excursion | |
4549 (funcall newsticker-html-renderer pos-text-start | |
4550 pos-text-end))) | |
4551 (cond ((eq newsticker-html-renderer 'w3m-region) | |
4552 (add-text-properties pos (point-max) | |
4553 (list 'keymap | |
4554 w3m-minor-mode-map))) | |
4555 ((eq newsticker-html-renderer 'w3-region) | |
4556 (add-text-properties pos (point-max) | |
4557 (list 'keymap w3-mode-map)))) | |
4558 (setq is-rendered-HTML t))) | |
4559 (error | |
4560 (message "Error: HTML rendering failed: %s, %s" | |
4561 (car error-data) (cdr error-data))))) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4562 ;; After html rendering there might be chunks of blank |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4563 ;; characters between rendered text and date, statistics or |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4564 ;; whatever. Remove it |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4565 (when (and (eq type 'item) is-rendered-HTML) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4566 (goto-char pos) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4567 (while (re-search-forward "[ \t]*\n[ \t]*" nil t) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4568 (replace-match " " nil nil)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4569 (goto-char (point-max))) |
65468 | 4570 (when (and newsticker-justification |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
4571 (memq type '(item desc)) |
65468 | 4572 (not is-rendered-HTML)) |
4573 (condition-case nil | |
4574 (let ((use-hard-newlines t)) | |
4575 (fill-region pos (point-max) newsticker-justification)) | |
4576 (error nil)))) | |
4577 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4578 ;; remove leading and trailing newlines |
65468 | 4579 (goto-char pos) |
4580 (unless (= 0 (skip-chars-forward " \t\r\n")) | |
4581 (delete-region pos (point))) | |
4582 (goto-char (point-max)) | |
4583 (let ((end (point))) | |
4584 (unless (= 0 (skip-chars-backward " \t\r\n" (1+ pos))) | |
4585 (delete-region (point) end))) | |
4586 (goto-char (point-max)) | |
4587 ;; closing newline | |
4588 (unless nil ;;(eq pos (point)) | |
4589 (insert "\n") | |
4590 (put-text-property (1- (point)) (point) 'hard t)) | |
4591 | |
4592 ;; insert enclosure element | |
4593 (when (eq type 'desc) | |
4594 (setq pos-enclosure-start (point)) | |
4595 (newsticker--buffer-insert-enclosure item) | |
4596 (setq pos-enclosure-end (point))) | |
4597 | |
4598 ;; show extra elements | |
4599 (when (eq type 'desc) | |
4600 (goto-char (point-max)) | |
4601 (setq pos-extra-start (point)) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4602 (newsticker--buffer-print-extra-elements item) |
65468 | 4603 (setq pos-extra-end (point))) |
4604 | |
4605 ;; text properties | |
4606 (when (memq type '(feed item)) | |
4607 (add-text-properties pos (1- (point)) | |
4608 (list 'mouse-face 'highlight | |
4609 'nt-link (newsticker--link item) | |
4610 'help-echo | |
4611 (format "mouse-2: visit item (%s)" | |
4612 (newsticker--link item)) | |
4613 'keymap newsticker--url-keymap)) | |
4614 (add-text-properties pos (point) | |
4615 (list 'nt-title (newsticker--title item) | |
4616 '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
|
4617 |
65468 | 4618 (add-text-properties pos (point) |
4619 (list 'nt-type type | |
4620 'nt-face type | |
4621 'nt-age age | |
4622 'nt-guid (newsticker--guid item))) | |
4623 (when (and pos-date-start pos-date-end) | |
4624 (put-text-property pos-date-start pos-date-end 'nt-face 'date)) | |
4625 (when (and pos-stat-start pos-stat-end) | |
4626 (put-text-property pos-stat-start pos-stat-end 'nt-face 'stat)) | |
4627 (when (and pos-extra-start pos-extra-end) | |
4628 (put-text-property pos-extra-start pos-extra-end | |
4629 'nt-face 'extra) | |
4630 (put-text-property pos-extra-start pos-extra-end | |
4631 'nt-type 'extra)) | |
4632 (when (and pos-enclosure-start pos-enclosure-end | |
4633 (> pos-enclosure-end pos-enclosure-start)) | |
4634 (put-text-property pos-enclosure-start (1- pos-enclosure-end) | |
4635 'nt-face 'enclosure)) | |
4636 | |
4637 ;; left margin | |
4638 ;;(unless (memq type '(feed item)) | |
4639 ;;(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
|
4640 |
65468 | 4641 ;; save rendered stuff |
4642 (cond ((eq type 'desc) | |
4643 ;; preformatted contents | |
4644 (newsticker--cache-set-preformatted-contents | |
4645 item (buffer-substring pos (point)))) | |
4646 ((eq type 'item) | |
4647 ;; preformatted title | |
4648 (newsticker--cache-set-preformatted-title | |
4649 item (buffer-substring pos (point))))))))) | |
4650 | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4651 (defun newsticker--buffer-print-extra-elements (item) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4652 "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
|
4653 (let ((ignored-elements '(items link title description |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4654 content:encoded |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4655 dc:subject dc:date item guid |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4656 pubDate enclosure)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4657 (left-column-width 1)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4658 (mapc (lambda (extra-element) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4659 (unless (memq (car extra-element) ignored-elements) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4660 (setq left-column-width (max left-column-width |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4661 (length (symbol-name |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4662 (car extra-element))))))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4663 (newsticker--extra item)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4664 (mapc (lambda (extra-element) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4665 (unless (memq (car extra-element) ignored-elements) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4666 (newsticker--buffer-do-print-extra-element extra-element |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4667 left-column-width))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4668 (newsticker--extra item)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4669 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4670 (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
|
4671 "Actually print an EXTRA-ELEMENT using the given WIDTH." |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4672 (let ((name (symbol-name (car extra-element)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4673 (insert (format "%s: " name)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4674 (insert (make-string (- width (length name)) ? ))) |
65468 | 4675 (let (;;(attributes (cadr extra-element)) ;FIXME!!!! |
4676 (contents (cddr extra-element))) | |
4677 (cond ((listp contents) | |
4678 (mapc (lambda (i) | |
4679 (if (and (stringp i) | |
4680 (string-match "^http://.*" i)) | |
4681 (let ((pos (point))) | |
4682 (insert i " ") ; avoid self-reference from the | |
4683 ; nt-link thing | |
4684 (add-text-properties | |
4685 pos (point) | |
4686 (list 'mouse-face 'highlight | |
4687 'nt-link i | |
4688 'help-echo | |
4689 (format "mouse-2: visit (%s)" i) | |
4690 'keymap newsticker--url-keymap))) | |
4691 (insert (format "%s" i)))) | |
4692 contents)) | |
4693 (t | |
4694 (insert (format "%s" contents)))) | |
4695 (insert "\n"))) | |
4696 | |
4697 (defun newsticker--buffer-insert-enclosure (item) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4698 "Insert enclosure element of a news ITEM into the current buffer." |
65468 | 4699 (let ((enclosure (newsticker--enclosure item)) |
4700 (beg (point))) | |
4701 (when enclosure | |
4702 (let ((url (cdr (assoc 'url enclosure))) | |
75606
b4a41bf661e9
(newsticker-version): Changed to "1.10".
Eli Zaretskii <eliz@gnu.org>
parents:
75347
diff
changeset
|
4703 (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
|
4704 "0"))) |
65468 | 4705 (type (cdr (assoc 'type enclosure)))) |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4706 (cond ((> length 1048576) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4707 (insert (format "Enclosed file (%s, %1.2f MBytes)" type |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4708 (/ length 1048576)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4709 ((> length 1024) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4710 (insert (format "Enclosed file (%s, %1.2f KBytes)" type |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
4711 (/ length 1024))))) |
65468 | 4712 (add-text-properties beg (point) |
4713 (list 'mouse-face 'highlight | |
4714 'nt-link url | |
4715 'help-echo (format | |
4716 "mouse-2: visit (%s)" url) | |
4717 'keymap newsticker--url-keymap | |
4718 'nt-face 'enclosure | |
4719 'nt-type 'desc)) | |
4720 (insert "\n"))))) | |
4721 | |
4722 (defun newsticker--buffer-statistics (feed-name-symbol) | |
4723 "Return a statistic string for the feed given by FEED-NAME-SYMBOL. | |
4724 See `newsticker-statistics-format'." | |
4725 (let ((case-fold-search nil)) | |
4726 (replace-regexp-in-string | |
4727 "%a" | |
4728 (format "%d" (newsticker--stat-num-items feed-name-symbol)) | |
4729 (replace-regexp-in-string | |
4730 "%i" | |
4731 (format "%d" (newsticker--stat-num-items feed-name-symbol 'immortal)) | |
4732 (replace-regexp-in-string | |
4733 "%n" | |
4734 (format "%d" (newsticker--stat-num-items feed-name-symbol 'new)) | |
4735 (replace-regexp-in-string | |
4736 "%o" | |
4737 (format "%d" (newsticker--stat-num-items feed-name-symbol 'old)) | |
4738 (replace-regexp-in-string | |
4739 "%O" | |
4740 (format "%d" (newsticker--stat-num-items feed-name-symbol 'obsolete)) | |
4741 newsticker-statistics-format))))))) | |
4742 | |
4743 (defun newsticker--buffer-set-faces (start end) | |
4744 "Add face properties according to mark property. | |
4745 Scans the buffer between START and END." | |
4746 (save-excursion | |
4747 ;;(put-text-property start end 'face 'newsticker-default-face) | |
4748 (goto-char start) | |
4749 (let ((pos1 start) | |
4750 (pos2 1) | |
4751 (nt-face (get-text-property start 'nt-face)) | |
4752 (nt-age (get-text-property start 'nt-age))) | |
4753 (when nt-face | |
4754 (setq pos2 (next-single-property-change (point) 'nt-face)) | |
4755 (newsticker--set-face-properties pos1 pos2 nt-face nt-age) | |
4756 (setq nt-face (get-text-property pos2 'nt-face)) | |
4757 (setq pos1 pos2)) | |
4758 (while (and (setq pos2 (next-single-property-change pos1 'nt-face)) | |
4759 (<= pos2 end) | |
4760 (> pos2 pos1)) | |
4761 (newsticker--set-face-properties pos1 pos2 nt-face nt-age) | |
4762 (setq nt-face (get-text-property pos2 'nt-face)) | |
4763 (setq nt-age (get-text-property pos2 'nt-age)) | |
4764 (setq pos1 pos2))))) | |
4765 | |
4766 (defun newsticker--buffer-set-invisibility (start end) | |
4767 "Add invisibility properties according to nt-type property. | |
4768 Scans the buffer between START and END. Sets the 'invisible | |
4769 property to '(<nt-type>-<nt-age> <nt-type> <nt-age>)." | |
4770 (save-excursion | |
4771 ;; reset invisibility settings | |
4772 (put-text-property start end 'invisible nil) | |
4773 ;; let's go | |
4774 (goto-char start) | |
4775 (let ((pos1 start) | |
4776 (pos2 1) | |
4777 (nt-type (get-text-property start 'nt-type)) | |
4778 (nt-age (get-text-property start 'nt-age))) | |
4779 (when nt-type | |
4780 (setq pos2 (next-single-property-change (point) 'nt-type)) | |
4781 (put-text-property (max (point-min) pos1) (1- pos2) | |
4782 'invisible | |
4783 (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
|
4784 (concat |
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
4785 (symbol-name |
65468 | 4786 (if (eq nt-type 'extra) 'desc nt-type)) |
4787 "-" | |
4788 (symbol-name nt-age))) | |
4789 nt-type | |
4790 nt-age)) | |
4791 (setq nt-type (get-text-property pos2 'nt-type)) | |
4792 (setq pos1 pos2)) | |
4793 (while (and (setq pos2 (next-single-property-change pos1 'nt-type)) | |
4794 (<= pos2 end) | |
4795 (> pos2 pos1)) | |
4796 ;; must shift one char to the left in order to handle inivisible | |
4797 ;; newlines, motion in invisible text areas and all that correctly | |
4798 (put-text-property (1- pos1) (1- pos2) | |
4799 'invisible | |
4800 (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
|
4801 (concat |
e3c81c2db803
(tool-bar-map, w3-mode-map, w3m-minor-mode-map): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents:
65481
diff
changeset
|
4802 (symbol-name |
65468 | 4803 (if (eq nt-type 'extra) 'desc nt-type)) |
4804 "-" | |
4805 (symbol-name nt-age))) | |
4806 nt-type | |
4807 nt-age)) | |
4808 (setq nt-type (get-text-property pos2 'nt-type)) | |
4809 (setq nt-age (get-text-property pos2 'nt-age)) | |
4810 (setq pos1 pos2))))) | |
4811 | |
4812 (defun newsticker--set-face-properties (pos1 pos2 nt-face age) | |
4813 "Set the face for the text between the positions POS1 and POS2. | |
4814 The face is chosen according the values of NT-FACE and AGE." | |
4815 (let ((face (cond ((eq nt-face 'feed) | |
4816 'newsticker-feed-face) | |
4817 ((eq nt-face 'item) | |
4818 (cond ((eq age 'new) | |
4819 'newsticker-new-item-face) | |
4820 ((eq age 'old) | |
4821 'newsticker-old-item-face) | |
4822 ((eq age 'immortal) | |
4823 'newsticker-immortal-item-face) | |
4824 ((eq age 'obsolete) | |
4825 'newsticker-obsolete-item-face))) | |
4826 ((eq nt-face 'date) | |
4827 'newsticker-date-face) | |
4828 ((eq nt-face 'stat) | |
4829 'newsticker-statistics-face) | |
4830 ((eq nt-face 'extra) | |
4831 'newsticker-extra-face) | |
4832 ((eq nt-face 'enclosure) | |
4833 'newsticker-enclosure-face)))) | |
4834 (when face | |
4835 (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
|
4836 |
65468 | 4837 (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
|
4838 "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
|
4839 (insert-image img string)) |
65468 | 4840 |
4841 ;; ====================================================================== | |
4842 ;;; HTML rendering | |
4843 ;; ====================================================================== | |
4844 (defun newsticker-htmlr-render (pos1 pos2) ; | |
4845 "Replacement for `htmlr-render'. | |
4846 Renders the HTML code in the region POS1 to POS2 using htmlr." | |
4847 (let ((str (buffer-substring-no-properties pos1 pos2))) | |
4848 (delete-region pos1 pos2) | |
4849 (insert | |
4850 (with-temp-buffer | |
4851 (insert str) | |
4852 (goto-char (point-min)) | |
4853 ;; begin original htmlr-render | |
4854 (htmlr-reset) | |
4855 ;; something omitted here... | |
4856 (while (< (point) (point-max)) | |
4857 (htmlr-step)) | |
4858 ;; end original htmlr-render | |
4859 (newsticker--remove-whitespace (buffer-string)))))) | |
4860 | |
4861 ;; ====================================================================== | |
4862 ;;; Functions working on the *newsticker* buffer | |
4863 ;; ====================================================================== | |
4864 (defun newsticker--buffer-make-item-completely-visible () | |
4865 "Scroll buffer until current item is completely visible." | |
4866 (when newsticker--auto-narrow-to-feed | |
4867 (let* ((min (or (save-excursion (newsticker--buffer-beginning-of-feed)) | |
4868 (point-min))) | |
4869 (max (or (save-excursion (newsticker--buffer-end-of-feed)) | |
4870 (point-max)))) | |
4871 (narrow-to-region min max))) | |
4872 (when newsticker--auto-narrow-to-item | |
4873 (let* ((min (or (save-excursion (newsticker--buffer-beginning-of-item)) | |
4874 (point-min))) | |
4875 (max (or (save-excursion (newsticker--buffer-end-of-item)) | |
4876 (point-max)))) | |
4877 (narrow-to-region min max))) | |
4878 (sit-for 0) | |
4879 ;; do not count lines and stuff because that does not work when images | |
4880 ;; are displayed. Do it the simple way: | |
4881 (save-excursion | |
4882 (newsticker--buffer-end-of-item) | |
4883 (unless (pos-visible-in-window-p) | |
4884 (recenter -1))) | |
4885 (unless (pos-visible-in-window-p) | |
4886 (recenter 0))) | |
4887 | |
4888 (defun newsticker--buffer-get-feed-title-at-point () | |
4889 "Return feed symbol of headline at point." | |
4890 (format "%s" (or (get-text-property (point) 'feed) " "))) | |
4891 | |
4892 (defun newsticker--buffer-get-item-title-at-point () | |
4893 "Return feed symbol of headline at point." | |
4894 (format "%s" (or (get-text-property (point) 'nt-title) " "))) | |
4895 | |
4896 (defun newsticker--buffer-goto (types &optional age backwards) | |
4897 "Search next occurrence of TYPES in current buffer. | |
4898 TYPES is a list of symbols. If TYPES is found point is moved, if | |
4899 not point is left unchanged. If optional parameter AGE is not | |
4900 nil, the type AND the age must match. If BACKWARDS is t, search | |
4901 backwards." | |
4902 (let ((pos (save-excursion | |
4903 (save-restriction | |
4904 (widen) | |
4905 (catch 'found | |
4906 (let ((tpos (point))) | |
4907 (while (setq tpos | |
4908 (if backwards | |
4909 (if (eq tpos (point-min)) | |
4910 nil | |
4911 (or (previous-single-property-change | |
4912 tpos 'nt-type) | |
4913 (point-min))) | |
4914 (next-single-property-change | |
4915 tpos 'nt-type))) | |
4916 (and (memq (get-text-property tpos 'nt-type) types) | |
4917 (or (not age) | |
4918 (eq (get-text-property tpos 'nt-age) age)) | |
4919 (throw 'found tpos))))))))) | |
4920 (when pos | |
4921 (goto-char pos)) | |
4922 pos)) | |
4923 | |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
4924 (defun newsticker--buffer-hideshow (mark-age onoff) |
65468 | 4925 "Hide or show items of type MARK-AGE. |
4926 If ONOFF is nil the item is hidden, otherwise it is shown." | |
4927 (if onoff | |
68573
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
4928 (remove-from-invisibility-spec mark-age) |
65468 | 4929 (add-to-invisibility-spec mark-age))) |
4930 | |
4931 (defun newsticker--buffer-beginning-of-item () | |
4932 "Move point to the beginning of the item at point. | |
4933 Return new position." | |
4934 (if (bobp) | |
4935 (point) | |
4936 (let ((type (get-text-property (point) 'nt-type)) | |
4937 (typebefore (get-text-property (1- (point)) 'nt-type))) | |
4938 (if (and (memq type '(item feed)) | |
4939 (not (eq type typebefore))) | |
4940 (point) | |
4941 (newsticker--buffer-goto '(item feed) nil t) | |
4942 (point))))) | |
4943 | |
4944 (defun newsticker--buffer-beginning-of-feed () | |
4945 "Move point to the beginning of the feed at point. | |
4946 Return new position." | |
4947 (if (bobp) | |
4948 (point) | |
4949 (let ((type (get-text-property (point) 'nt-type)) | |
4950 (typebefore (get-text-property (1- (point)) 'nt-type))) | |
4951 (if (and (memq type '(feed)) | |
4952 (not (eq type typebefore))) | |
4953 (point) | |
4954 (newsticker--buffer-goto '(feed) nil t) | |
4955 (point))))) | |
4956 | |
4957 (defun newsticker--buffer-end-of-item () | |
4958 "Move point to the end of the item at point. | |
4959 Take care: end of item is at the end of its last line!" | |
4960 (when (newsticker--buffer-goto '(item feed nil)) | |
4961 (point))) | |
4962 | |
4963 (defun newsticker--buffer-end-of-feed () | |
4964 "Move point to the end of the last item of the feed at point. | |
4965 Take care: end of item is at the end of its last line!" | |
4966 (when (newsticker--buffer-goto '(feed nil)) | |
4967 (backward-char 1) | |
4968 (point))) | |
4969 | |
4970 ;; ====================================================================== | |
4971 ;;; manipulation of ticker text | |
4972 ;; ====================================================================== | |
4973 (defun newsticker--ticker-text-setup () | |
4974 "Build the ticker text which is scrolled or flashed in the echo area." | |
4975 ;; reset scrollable text | |
4976 (setq newsticker--scrollable-text "") | |
4977 (setq newsticker--item-list nil) | |
4978 (setq newsticker--item-position 0) | |
4979 ;; build scrollable text from cache data | |
4980 (let ((have-something nil)) | |
4981 (mapc | |
4982 (lambda (feed) | |
4983 (let ((feed-name (symbol-name (car feed)))) | |
4984 (let ((num-new (newsticker--stat-num-items (car feed) 'new)) | |
4985 (num-old (newsticker--stat-num-items (car feed) 'old)) | |
4986 (num-imm (newsticker--stat-num-items (car feed) 'immortal)) | |
4987 (num-obs (newsticker--stat-num-items (car feed) 'obsolete))) | |
4988 (when (or (> num-new 0) | |
4989 (and (> num-old 0) | |
4990 (not newsticker-hide-old-items-in-echo-area)) | |
4991 (and (> num-imm 0) | |
4992 (not newsticker-hide-immortal-items-in-echo-area)) | |
4993 (and (> num-obs 0) | |
4994 (not newsticker-hide-obsolete-items-in-echo-area))) | |
4995 (setq have-something t) | |
4996 (mapc | |
4997 (lambda (item) | |
4998 (let ((title (replace-regexp-in-string | |
4999 "[\r\n]+" " " | |
5000 (newsticker--title item))) | |
5001 (age (newsticker--age item))) | |
5002 (unless (string= title newsticker--error-headline) | |
5003 (when | |
5004 (or (eq age 'new) | |
5005 (and (eq age 'old) | |
5006 (not newsticker-hide-old-items-in-echo-area)) | |
5007 (and (eq age 'obsolete) | |
5008 (not | |
5009 newsticker-hide-obsolete-items-in-echo-area)) | |
5010 (and (eq age 'immortal) | |
5011 (not | |
5012 newsticker-hide-immortal-items-in-echo-area))) | |
5013 (setq title (newsticker--remove-whitespace title)) | |
5014 ;; add to flash list | |
5015 (add-to-list 'newsticker--item-list | |
5016 (concat feed-name ": " title) t) | |
5017 ;; and to the scrollable text | |
5018 (setq newsticker--scrollable-text | |
5019 (concat newsticker--scrollable-text | |
5020 " " feed-name ": " title " +++")))))) | |
5021 (cdr feed)))))) | |
5022 newsticker--cache) | |
5023 (when have-something | |
5024 (setq newsticker--scrollable-text | |
5025 (concat "+++ " | |
5026 (format-time-string "%A, %H:%M" | |
5027 newsticker--latest-update-time) | |
5028 " ++++++" newsticker--scrollable-text))))) | |
5029 | |
5030 (defun newsticker--ticker-text-remove (feed title) | |
5031 "Remove the item of FEED with TITLE from the ticker text." | |
5032 ;; reset scrollable text | |
5033 (setq newsticker--item-position 0) | |
5034 (let ((feed-name (symbol-name feed)) | |
5035 (t-title (replace-regexp-in-string "[\r\n]+" " " title))) | |
5036 ;; remove from flash list | |
5037 (setq newsticker--item-list (remove (concat feed-name ": " t-title) | |
5038 newsticker--item-list)) | |
5039 ;; and from the scrollable text | |
5040 (setq newsticker--scrollable-text | |
5041 (replace-regexp-in-string | |
5042 (regexp-quote (concat " " feed-name ": " t-title " +++")) | |
5043 "" | |
5044 newsticker--scrollable-text)) | |
5045 (if (string-match (concat "^\\+\\+\\+ [A-Z][a-z]+, " | |
5046 "[012]?[0-9]:[0-9][0-9] \\+\\+\\+\\+\\+\\+$") | |
5047 newsticker--scrollable-text) | |
5048 (setq newsticker--scrollable-text "")))) | |
5049 | |
5050 ;; ====================================================================== | |
5051 ;;; manipulation of cached data | |
5052 ;; ====================================================================== | |
5053 (defun newsticker--cache-set-preformatted-contents (item contents) | |
5054 "Set preformatted contents of ITEM to CONTENTS." | |
5055 (if (nthcdr 6 item) | |
5056 (setcar (nthcdr 6 item) contents) | |
5057 (setcdr (nthcdr 5 item) (list contents)))) | |
5058 | |
5059 (defun newsticker--cache-set-preformatted-title (item title) | |
5060 "Set preformatted title of ITEM to TITLE." | |
5061 (if (nthcdr 7 item) | |
5062 (setcar (nthcdr 7 item) title) | |
5063 (setcdr (nthcdr 6 item) title))) | |
5064 | |
5065 (defun newsticker--cache-replace-age (data feed old-age new-age) | |
5066 "Mark all items in DATA in FEED which carry age OLD-AGE with NEW-AGE. | |
5067 If FEED is 'any it applies to all feeds. If OLD-AGE is 'any, | |
5068 all marks are replaced by NEW-AGE. Removes all pre-formatted contents." | |
5069 (mapc (lambda (a-feed) | |
5070 (when (or (eq feed 'any) | |
5071 (eq (car a-feed) feed)) | |
5072 (let ((items (cdr a-feed))) | |
5073 (mapc (lambda (item) | |
5074 (when (or (eq old-age 'any) | |
5075 (eq (newsticker--age item) old-age)) | |
5076 (setcar (nthcdr 4 item) new-age) | |
5077 (newsticker--do-forget-preformatted item))) | |
5078 items)))) | |
5079 data) | |
5080 data) | |
5081 | |
5082 (defun newsticker--cache-mark-expired (data feed old-age new-age time) | |
5083 "Mark all expired entries. | |
5084 This function sets the age entries in DATA in the feed FEED. If | |
5085 an item's age is OLD-AGE it is set to NEW-AGE if the item is | |
5086 older than TIME." | |
5087 (mapc | |
5088 (lambda (a-feed) | |
5089 (when (or (eq feed 'any) | |
5090 (eq (car a-feed) feed)) | |
5091 (let ((items (cdr a-feed))) | |
5092 (mapc | |
5093 (lambda (item) | |
5094 (when (eq (newsticker--age item) old-age) | |
5095 (let ((exp-time (time-add (newsticker--time item) | |
5096 (seconds-to-time time)))) | |
5097 (when (time-less-p exp-time (current-time)) | |
5098 (newsticker--debug-msg | |
5099 "Item `%s' from %s has expired on %s" | |
5100 (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
|
5101 (format-time-string "%Y-%02m-%d, %H:%M" |
65468 | 5102 (newsticker--time item)) |
5103 (format-time-string "%Y-%02m-%d, %H:%M" exp-time)) | |
5104 (setcar (nthcdr 4 item) new-age))))) | |
5105 items)))) | |
5106 data) | |
5107 data) | |
5108 | |
5109 (defun newsticker--cache-contains (data feed title desc link age | |
5110 &optional guid) | |
5111 "Check DATA whether FEED contains an item with the given properties. | |
5112 This function returns the contained item or nil if it is not | |
5113 contained. | |
5114 The properties which are checked are TITLE, DESC, LINK, AGE, and | |
5115 GUID. In general all properties must match in order to return a | |
5116 certain item, except for the following cases. | |
5117 | |
5118 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
|
5119 matter. If DESC is nil it is ignored as well. If |
65468 | 5120 `newsticker-desc-comp-max' is non-nil, only the first |
5121 `newsticker-desc-comp-max' characters of DESC are taken into | |
5122 account. | |
5123 | |
5124 If GUID is non-nil it is sufficient to match this value, and the | |
5125 other properties are ignored." | |
5126 (condition-case nil | |
5127 (catch 'found | |
5128 (when (and desc newsticker-desc-comp-max | |
5129 (> (length desc) newsticker-desc-comp-max)) | |
5130 (setq desc (substring desc 0 newsticker-desc-comp-max))) | |
5131 (mapc | |
5132 (lambda (this-feed) | |
5133 (when (eq (car this-feed) feed) | |
5134 (mapc (lambda (anitem) | |
5135 (when (or | |
5136 ;; global unique id can match | |
5137 (and guid | |
5138 (string= guid (newsticker--guid anitem))) | |
5139 ;; or title, desc, etc. | |
5140 (and | |
5141 ;;(or (not (eq age 'feed)) | |
5142 ;; (eq (newsticker--age anitem) 'feed)) | |
5143 (string= (newsticker--title anitem) | |
5144 title) | |
5145 (or (not link) | |
5146 (string= (newsticker--link anitem) | |
5147 link)) | |
5148 (or (not desc) | |
5149 (if (and desc newsticker-desc-comp-max | |
5150 (> (length (newsticker--desc anitem)) | |
5151 newsticker-desc-comp-max)) | |
5152 (string= (substring | |
5153 (newsticker--desc anitem) | |
5154 0 newsticker-desc-comp-max) | |
5155 desc) | |
5156 (string= (newsticker--desc anitem) | |
5157 desc))))) | |
5158 (throw 'found anitem))) | |
5159 (cdr this-feed)))) | |
5160 data) | |
5161 nil) | |
5162 (error nil))) | |
5163 | |
5164 (defun newsticker--cache-add (data feed-name-symbol title desc link time age | |
5165 position extra-elements | |
5166 &optional updated-age updated-time | |
5167 preformatted-contents | |
5168 preformatted-title) | |
5169 "Add another item to cache data. | |
5170 Add to DATA in the FEED-NAME-SYMBOL an item with TITLE, DESC, | |
5171 LINK, TIME, AGE, POSITION, and EXTRA-ELEMENTS. If this item is | |
5172 contained already, its mark is set to UPDATED-AGE, its time is | |
5173 set to UPDATED-TIME, and its pre-formatted contents is set to | |
5174 PREFORMATTED-CONTENTS and PREFORMATTED-TITLE. Returns the age | |
5175 which the item got." | |
5176 (let ((item (newsticker--cache-contains data feed-name-symbol title | |
5177 desc link age))) | |
5178 (if item | |
5179 ;; does exist already -- change age, update time and position | |
5180 (progn | |
5181 (if (nthcdr 5 item) | |
5182 (setcar (nthcdr 5 item) position) | |
5183 (setcdr (nthcdr 4 item) (list position))) | |
5184 (setcar (nthcdr 4 item) updated-age) | |
5185 (if updated-time | |
5186 (setcar (nthcdr 3 item) updated-time)) | |
5187 ;; replace cached pre-formatted contents | |
5188 (newsticker--cache-set-preformatted-contents | |
5189 item preformatted-contents) | |
5190 (newsticker--cache-set-preformatted-title | |
5191 item preformatted-title)) | |
5192 ;; did not exist or age equals 'feed-name-symbol | |
5193 (catch 'found | |
5194 (mapc (lambda (this-feed) | |
5195 (when (eq (car this-feed) feed-name-symbol) | |
5196 (setcdr this-feed (nconc (cdr this-feed) | |
5197 (list (list title desc link | |
5198 time age position | |
5199 preformatted-contents | |
5200 preformatted-title | |
5201 extra-elements)))) | |
5202 (throw 'found this-feed))) | |
5203 data) | |
5204 ;; the feed is not contained | |
5205 (add-to-list 'data (list feed-name-symbol | |
5206 (list title desc link time age position | |
5207 preformatted-contents | |
5208 preformatted-title | |
5209 extra-elements)) | |
5210 t)))) | |
5211 data) | |
5212 | |
5213 (defun newsticker--cache-remove (data feed-symbol age) | |
5214 "Remove all entries from DATA in the feed FEED-SYMBOL with AGE. | |
5215 FEED-SYMBOL may be 'any. Entries from old feeds, which are no longer in | |
5216 `newsticker-url-list' or `newsticker-url-list-defaults', are removed as | |
5217 well." | |
5218 (let* ((pos data) | |
5219 (feed (car pos)) | |
5220 (last-pos nil)) | |
5221 (while feed | |
5222 (if (or (assoc (symbol-name (car feed)) newsticker-url-list) | |
5223 (assoc (symbol-name (car feed)) newsticker-url-list-defaults)) | |
5224 ;; feed is still valid=active | |
5225 ;; (message "Keeping feed %s" (car feed)) | |
5226 (if (or (eq feed-symbol 'any) | |
5227 (eq feed-symbol (car feed))) | |
5228 (let* ((item-pos (cdr feed)) | |
5229 (item (car item-pos)) | |
5230 (prev-pos nil)) | |
5231 (while item | |
5232 ;;(message "%s" (car item)) | |
5233 (if (eq age (newsticker--age item)) | |
5234 ;; remove this item | |
5235 (progn | |
5236 ;;(message "Removing item %s" (car item)) | |
5237 (if prev-pos | |
5238 (setcdr prev-pos (cdr item-pos)) | |
5239 (setcdr feed (cdr item-pos)))) | |
5240 ;;(message "Keeping item %s" (car item)) | |
5241 (setq prev-pos item-pos)) | |
5242 (setq item-pos (cdr item-pos)) | |
5243 (setq item (car item-pos))))) | |
5244 ;; feed is not active anymore | |
5245 ;; (message "Removing feed %s" (car feed)) | |
5246 (if last-pos | |
5247 (setcdr last-pos (cdr pos)) | |
5248 (setq data (cdr pos)))) | |
5249 (setq last-pos pos) | |
5250 (setq pos (cdr pos)) | |
5251 (setq feed (car pos))))) | |
5252 | |
5253 ;; ====================================================================== | |
5254 ;;; Sorting | |
5255 ;; ====================================================================== | |
5256 (defun newsticker--cache-item-compare-by-time (item1 item2) | |
5257 "Compare two news items ITEM1 and ITEM2 by comparing their time values." | |
5258 (catch 'result | |
5259 (let ((age1 (newsticker--age item1)) | |
5260 (age2 (newsticker--age item2))) | |
5261 (if (not (eq age1 age2)) | |
5262 (cond ((eq age1 'obsolete) | |
5263 (throw 'result nil)) | |
5264 ((eq age2 'obsolete) | |
5265 (throw 'result t))))) | |
5266 (let* ((time1 (newsticker--time item1)) | |
5267 (time2 (newsticker--time item2))) | |
5268 (cond ((< (nth 0 time1) (nth 0 time2)) | |
5269 nil) | |
5270 ((> (nth 0 time1) (nth 0 time2)) | |
5271 t) | |
5272 ((< (nth 1 time1) (nth 1 time2)) | |
5273 nil) | |
5274 ((> (nth 1 time1) (nth 1 time2)) | |
5275 t) | |
5276 ((< (or (nth 2 time1) 0) (or (nth 2 time2) 0)) | |
5277 nil) | |
5278 ((> (or (nth 2 time1) 0) (or (nth 2 time2) 0)) | |
5279 t) | |
5280 (t | |
5281 nil))))) | |
5282 | |
5283 (defun newsticker--cache-item-compare-by-title (item1 item2) | |
5284 "Compare ITEM1 and ITEM2 by comparing their titles." | |
5285 (catch 'result | |
5286 (let ((age1 (newsticker--age item1)) | |
5287 (age2 (newsticker--age item2))) | |
5288 (if (not (eq age1 age2)) | |
5289 (cond ((eq age1 'obsolete) | |
5290 (throw 'result nil)) | |
5291 ((eq age2 'obsolete) | |
5292 (throw 'result t))))) | |
5293 (string< (newsticker--title item1) (newsticker--title item2)))) | |
5294 | |
5295 (defun newsticker--cache-item-compare-by-position (item1 item2) | |
5296 "Compare ITEM1 and ITEM2 by comparing their original positions." | |
5297 (catch 'result | |
5298 (let ((age1 (newsticker--age item1)) | |
5299 (age2 (newsticker--age item2))) | |
5300 (if (not (eq age1 age2)) | |
5301 (cond ((eq age1 'obsolete) | |
5302 (throw 'result nil)) | |
5303 ((eq age2 'obsolete) | |
5304 (throw 'result t))))) | |
5305 (< (or (newsticker--pos item1) 0) (or (newsticker--pos item2) 0)))) | |
5306 | |
5307 (defun newsticker--cache-sort () | |
5308 "Sort the newsticker cache data." | |
5309 (let ((sort-fun (cond ((eq newsticker-sort-method 'sort-by-time) | |
5310 'newsticker--cache-item-compare-by-time) | |
5311 ((eq newsticker-sort-method 'sort-by-title) | |
5312 'newsticker--cache-item-compare-by-title) | |
5313 ((eq newsticker-sort-method 'sort-by-original-order) | |
5314 'newsticker--cache-item-compare-by-position)))) | |
5315 (mapc (lambda (feed-list) | |
5316 (setcdr feed-list (sort (cdr feed-list) | |
5317 sort-fun))) | |
5318 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
|
5319 |
65468 | 5320 (defun newsticker--cache-update (&optional save) |
5321 "Update newsticker cache file. | |
5322 If optional argument SAVE is not nil the cache file is saved to disk." | |
5323 (save-excursion | |
5324 (let ((coding-system-for-write 'utf-8) | |
5325 (buf (find-file-noselect newsticker-cache-filename))) | |
5326 (when buf | |
5327 (set-buffer buf) | |
5328 (setq buffer-undo-list t) | |
5329 (erase-buffer) | |
5330 (insert ";; -*- coding: utf-8 -*-\n") | |
5331 (insert (prin1-to-string newsticker--cache)) | |
5332 (when save | |
5333 (save-buffer)))))) | |
5334 | |
5335 (defun newsticker--cache-get-feed (feed) | |
5336 "Return the cached data for the feed FEED. | |
5337 FEED is a symbol!" | |
5338 (assoc feed newsticker--cache)) | |
5339 | |
5340 ;; ====================================================================== | |
5341 ;;; Statistics | |
5342 ;; ====================================================================== | |
5343 (defun newsticker--stat-num-items (feed &optional age) | |
5344 "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
|
5345 If AGE is nil, the total number of items is returned." |
65468 | 5346 (let ((items (cdr (newsticker--cache-get-feed feed))) |
5347 (num 0)) | |
5348 (while items | |
5349 (if age | |
5350 (if (eq (newsticker--age (car items)) age) | |
5351 (setq num (1+ num))) | |
5352 (if (memq (newsticker--age (car items)) '(new old immortal obsolete)) | |
5353 (setq num (1+ num)))) | |
5354 (setq items (cdr items))) | |
5355 num)) | |
5356 | |
5357 ;; ====================================================================== | |
5358 ;;; OPML | |
5359 ;; ====================================================================== | |
5360 (defun newsticker-opml-export () | |
5361 "OPML subscription export. | |
5362 Export subscriptions to a buffer in OPML Format." | |
5363 (interactive) | |
5364 (with-current-buffer (get-buffer-create "*OPML Export*") | |
5365 (set-buffer-file-coding-system 'utf-8) | |
5366 (insert (concat | |
5367 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" | |
5368 "<!-- OPML generated by Emacs newsticker.el -->\n" | |
5369 "<opml version=\"1.0\">\n" | |
5370 " <head>\n" | |
5371 " <title>mySubscriptions</title>\n" | |
5372 " <dateCreated>" (format-time-string "%a, %d %b %Y %T %z") | |
5373 "</dateCreated>\n" | |
5374 " <ownerEmail>" user-mail-address "</ownerEmail>\n" | |
5375 " <ownerName>" (user-full-name) "</ownerName>\n" | |
5376 " </head>\n" | |
5377 " <body>\n")) | |
5378 (mapc (lambda (sub) | |
5379 (insert " <outline text=\"") | |
5380 (insert (newsticker--title sub)) | |
5381 (insert "\" xmlUrl=\"") | |
5382 (insert (cadr sub)) | |
5383 (insert "\"/>\n")) | |
5384 (append newsticker-url-list newsticker-url-list-defaults)) | |
5385 (insert " </body>\n</opml>\n")) | |
5386 (pop-to-buffer "*OPML Export*") | |
5387 (when (fboundp 'sgml-mode) | |
5388 (sgml-mode))) | |
5389 | |
5390 (defun newsticker-opml-import (filename) | |
5391 "Import OPML data from FILENAME." | |
5392 (interactive "fOPML file: ") | |
5393 (set-buffer (find-file-noselect filename)) | |
5394 (goto-char (point-min)) | |
5395 (let* ((node-list (xml-parse-region (point-min) (point-max))) | |
5396 (body (car (xml-get-children (car node-list) 'body))) | |
5397 (outlines (xml-get-children body 'outline))) | |
5398 (mapc (lambda (outline) | |
5399 (let ((name (xml-get-attribute outline 'text)) | |
5400 (url (xml-get-attribute outline 'xmlUrl))) | |
5401 (add-to-list 'newsticker-url-list | |
5402 (list name url nil nil nil) t))) | |
5403 outlines)) | |
5404 (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
|
5405 |
65468 | 5406 ;; ====================================================================== |
5407 ;;; Auto marking | |
5408 ;; ====================================================================== | |
5409 (defun newsticker--run-auto-mark-filter (feed item) | |
5410 "Automatically mark an item as old or immortal. | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5411 This function checks the variable `newsticker-auto-mark-filter-list' |
65468 | 5412 for an entry that matches FEED and ITEM." |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5413 (let ((case-fold-search t)) |
65468 | 5414 (mapc (lambda (filter) |
5415 (let ((filter-feed (car filter)) | |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5416 (pattern-list (cadr filter))) |
65468 | 5417 (when (string-match filter-feed feed) |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5418 (newsticker--do-run-auto-mark-filter item pattern-list)))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5419 newsticker-auto-mark-filter-list))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5420 |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5421 (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
|
5422 "Actually compare ITEM against the pattern-LIST |
f6bc825f1a5b
(newsticker--decode-iso8601-date, newsticker--set-customvar,
Juanma Barranquero <lekktu@gmail.com>
parents:
67593
diff
changeset
|
5423 \(from `newsticker-auto-mark-filter-list')." |
65468 | 5424 (mapc (lambda (pattern) |
66704
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5425 (let ((age (nth 0 pattern)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5426 (place (nth 1 pattern)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5427 (regexp (nth 2 pattern)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5428 (title (newsticker--title item)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5429 (desc (newsticker--desc item))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5430 (when (or (eq place 'title) (eq place 'all)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5431 (when (and title (string-match regexp title)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5432 (newsticker--debug-msg "Auto-marking as %s: `%s'" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5433 age (newsticker--title item)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5434 (setcar (nthcdr 4 item) age))) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5435 (when (or (eq place 'description) (eq place 'all)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5436 (when (and desc (string-match regexp desc)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5437 (newsticker--debug-msg "Auto-marking as %s: `%s'" |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5438 age (newsticker--title item)) |
768e9c3f6b5a
Commentary updated. Code formatting changed.
Eli Zaretskii <eliz@gnu.org>
parents:
65998
diff
changeset
|
5439 (setcar (nthcdr 4 item) age))))) |
65468 | 5440 list)) |
5441 | |
5442 | |
5443 ;; ====================================================================== | |
5444 ;;; hook samples | |
5445 ;; ====================================================================== | |
5446 (defun newsticker-new-item-functions-sample (feed item) | |
5447 "Demonstrate the use of the `newsticker-new-item-functions' hook. | |
5448 This function just prints out the values of the FEED and title of the ITEM." | |
5449 (message (concat "newsticker-new-item-functions-sample: feed=`%s', " | |
5450 "title=`%s'") | |
5451 feed (newsticker--title item))) | |
5452 | |
5453 (defun newsticker-download-images (feed item) | |
5454 "Download the first image. | |
5455 If FEED equals \"imagefeed\" download the first image URL found | |
5456 in the description=contents of ITEM to the directory | |
5457 \"~/tmp/newsticker/FEED/TITLE\" where TITLE is the title of the item." | |
5458 (when (string= feed "imagefeed") | |
5459 (let ((title (newsticker--title item)) | |
5460 (desc (newsticker--desc item))) | |
5461 (when (string-match "<img src=\"\\(http://[^ \"]+\\)\"" desc) | |
5462 (let ((url (substring desc (match-beginning 1) (match-end 1))) | |
5463 (temp-dir (concat "~/tmp/newsticker/" feed "/" title)) | |
5464 (org-dir default-directory)) | |
5465 (unless (file-directory-p temp-dir) | |
5466 (make-directory temp-dir t)) | |
5467 (cd temp-dir) | |
5468 (message "Getting image %s" url) | |
5469 (apply 'start-process "wget-image" | |
5470 " *newsticker-wget-download-images*" | |
5471 newsticker-wget-name | |
5472 (list url)) | |
5473 (cd org-dir)))))) | |
5474 | |
5475 (defun newsticker-download-enclosures (feed item) | |
5476 "In all FEEDs download the enclosed object of the news ITEM. | |
5477 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
|
5478 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
|
5479 item. Argument FEED is ignored. |
65468 | 5480 This function is suited for adding it to `newsticker-new-item-functions'." |
5481 (let ((title (newsticker--title item)) | |
5482 (enclosure (newsticker--enclosure item))) | |
5483 (when enclosure | |
5484 (let ((url (cdr (assoc 'url enclosure))) | |
5485 (temp-dir (concat "~/tmp/newsticker/" feed "/" title)) | |
5486 (org-dir default-directory)) | |
5487 (unless (file-directory-p temp-dir) | |
5488 (make-directory temp-dir t)) | |
5489 (cd temp-dir) | |
5490 (message "Getting enclosure %s" url) | |
5491 (apply 'start-process "wget-enclosure" | |
5492 " *newsticker-wget-download-enclosures*" | |
5493 newsticker-wget-name | |
5494 (list url)) | |
5495 (cd org-dir))))) | |
5496 | |
5497 | |
5498 (provide 'newsticker) | |
5499 | |
65481 | 5500 ;; arch-tag: ab761dfa-67bc-4207-bc64-4307271dc381 |
65468 | 5501 ;;; newsticker.el ends here |