annotate lisp/net/newsticker-treeview.el @ 95841:b4e36ff621b3

Add some compiler declarations, for builds without X.
author Glenn Morris <rgm@gnu.org>
date Thu, 12 Jun 2008 03:56:20 +0000
parents 690f0991195a
children 91e240b4d487
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
95679
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1 ;;; newsticker-treeview.el --- Treeview frontend for newsticker.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
2
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
3 ;; Copyright (C) 2008 Free Software Foundation, Inc.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
4
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
5 ;; Author: Ulf Jasper <ulf.jasper@web.de>
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
6 ;; Filename: newsticker-treeview.el
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
7 ;; URL: http://www.nongnu.org/newsticker
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
8 ;; Created: 2007
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
9 ;; Keywords: News, RSS, Atom
95685
ed883167b994 Autoload cookies for newsticker.
Ulf Jasper <ulf.jasper@web.de>
parents: 95684
diff changeset
10 ;; Time-stamp: "8. Juni 2008, 20:42:16 (ulf)"
95766
690f0991195a Header formatting fix.
Glenn Morris <rgm@gnu.org>
parents: 95760
diff changeset
11 ;; CVS-Version: $Id: newsticker-treeview.el,v 1.5 2008/06/10 03:15:43 gm Exp $
95679
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
12
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
13 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
14
95766
690f0991195a Header formatting fix.
Glenn Morris <rgm@gnu.org>
parents: 95760
diff changeset
15 ;; This file is part of GNU Emacs.
690f0991195a Header formatting fix.
Glenn Morris <rgm@gnu.org>
parents: 95760
diff changeset
16
95679
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
17 ;; GNU Emacs is free software: you can redistribute it and/or modify
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
18 ;; it under the terms of the GNU General Public License as published by
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
19 ;; the Free Software Foundation, either version 3 of the License, or
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
20 ;; (at your option) any later version.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
21
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
22 ;; GNU Emacs is distributed in the hope that it will be useful,
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
23 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
24 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
25 ;; GNU General Public License for more details.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
26
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
27 ;; You should have received a copy of the GNU General Public License
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
28 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
29
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
30 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
31 ;;; Commentary:
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
32
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
33 ;; See newsticker.el
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
34
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
35 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
36 ;;; History:
95760
e62f5d3e9fad Remove trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 95753
diff changeset
37 ;;
95679
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
38
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
39
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
40 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
41 ;;; Code:
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
42 (require 'newsticker-reader)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
43 (require 'widget)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
44 (require 'tree-widget)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
45 (require 'wid-edit)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
46
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
47 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
48 ;;; Customization
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
49 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
50 (defgroup newsticker-treeview nil
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
51 "Settings for the tree view reader."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
52 :group 'newsticker-reader)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
53
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
54 (defface newsticker-treeview-face
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
55 '((((class color) (background dark))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
56 (:family "helvetica" :foreground "misty rose" :bold nil))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
57 (((class color) (background light))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
58 (:family "helvetica" :foreground "black" :bold nil)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
59 "Face for newsticker tree."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
60 :group 'newsticker-treeview)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
61
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
62 (defface newsticker-treeview-new-face
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
63 '((((class color) (background dark))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
64 (:inherit newsticker-treeview-face :bold t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
65 (((class color) (background light))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
66 (:inherit newsticker-treeview-face :bold t)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
67 "Face for newsticker tree."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
68 :group 'newsticker-treeview)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
69
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
70 (defface newsticker-treeview-old-face
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
71 '((((class color) (background dark))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
72 (:inherit newsticker-treeview-face))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
73 (((class color) (background light))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
74 (:inherit newsticker-treeview-face)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
75 "Face for newsticker tree."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
76 :group 'newsticker-treeview)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
77
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
78 (defface newsticker-treeview-immortal-face
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
79 '((((class color) (background dark))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
80 (:inherit newsticker-treeview-face :foreground "orange" :italic t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
81 (((class color) (background light))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
82 (:inherit newsticker-treeview-face :foreground "blue" :italic t)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
83 "Face for newsticker tree."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
84 :group 'newsticker-treeview)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
85
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
86 (defface newsticker-treeview-obsolete-face
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
87 '((((class color) (background dark))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
88 (:inherit newsticker-treeview-face :strike-through t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
89 (((class color) (background light))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
90 (:inherit newsticker-treeview-face :strike-through t)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
91 "Face for newsticker tree."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
92 :group 'newsticker-treeview)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
93
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
94 (defface newsticker-treeview-selection-face
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
95 '((((class color) (background dark))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
96 (:background "#bbbbff"))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
97 (((class color) (background light))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
98 (:background "#bbbbff")))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
99 "Face for newsticker selection."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
100 :group 'newsticker-treeview)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
101
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
102 (defcustom newsticker-treeview-own-frame
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
103 t
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
104 "Decides whether newsticker creates and uses its own frame."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
105 :type 'boolean
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
106 :group 'newsticker-treeview)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
107
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
108 (defcustom newsticker-treeview-automatically-mark-displayed-items-as-old
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
109 t
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
110 "Decides whether to automatically mark displayed items as old.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
111 If t an item is marked as old as soon as it is displayed. This
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
112 applies to newsticker only."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
113 :type 'boolean
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
114 :group 'newsticker-treeview)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
115
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
116 (defvar newsticker-groups
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
117 '("Feeds")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
118 "List of feed groups, used in the treeview frontend.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
119 Each element must be a list consisting of strings. The first
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
120 element gives the title of the group, the following elements the
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
121 names of feeds that belong to the group.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
122 FIXME")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
123
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
124 (defcustom newsticker-groups-filename
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
125 "~/.newsticker-groups"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
126 "Name of the newsticker groups settings file."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
127 :type 'string
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
128 :group 'newsticker-treeview)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
129
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
130 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
131 ;;; internal variables
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
132 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
133 (defvar newsticker--treeview-windows nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
134 (defvar newsticker--treeview-buffers nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
135 (defvar newsticker--treeview-current-feed nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
136 (defvar newsticker--treeview-current-vfeed nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
137 (defvar newsticker--treeview-list-show-feed nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
138 (defvar newsticker--saved-window-config nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
139 (defvar newsticker--window-config nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
140 ;; (makunbound 'newsticker--selection-overlay) ;; FIXME
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
141 (defvar newsticker--selection-overlay nil
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
142 "Highlight the selected tree node.")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
143 ;;(makunbound 'newsticker--tree-selection-overlay) ;; FIXME
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
144 (defvar newsticker--tree-selection-overlay nil
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
145 "Highlight the selected list item.")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
146 ;;(makunbound 'newsticker--frame);; FIXME
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
147 (defvar newsticker--frame nil "Special frame for newsticker windows.")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
148 (defvar newsticker--treeview-list-sort-order 'sort-by-time)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
149 (defvar newsticker--treeview-current-node-id nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
150 (defvar newsticker--treeview-current-tree nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
151 (defvar newsticker--treeview-feed-tree nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
152 (defvar newsticker--treeview-vfeed-tree nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
153
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
154 ;; maps for the clickable portions
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
155 (defvar newsticker--treeview-url-keymap
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
156 (let ((map (make-sparse-keymap 'newsticker--treeview-url-keymap)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
157 (define-key map [mouse-1] 'newsticker-treeview-mouse-browse-url)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
158 (define-key map [mouse-2] 'newsticker-treeview-mouse-browse-url)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
159 (define-key map "\n" 'newsticker-treeview-browse-url)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
160 (define-key map "\C-m" 'newsticker-treeview-browse-url)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
161 (define-key map [(control return)] 'newsticker-handle-url)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
162 map)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
163 "Key map for click-able headings in the newsticker treeview buffers.")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
164
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
165
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
166 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
167 ;;; short cuts
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
168 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
169 (defsubst newsticker--treeview-tree-buffer ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
170 "Return the tree buffer of the newsticker treeview."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
171 (nth 0 newsticker--treeview-buffers))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
172 (defsubst newsticker--treeview-list-buffer ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
173 "Return the list buffer of the newsticker treeview."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
174 (nth 1 newsticker--treeview-buffers))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
175 (defsubst newsticker--treeview-item-buffer ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
176 "Return the item buffer of the newsticker treeview."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
177 (nth 2 newsticker--treeview-buffers))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
178 (defsubst newsticker--treeview-tree-window ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
179 "Return the tree window of the newsticker treeview."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
180 (nth 0 newsticker--treeview-windows))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
181 (defsubst newsticker--treeview-list-window ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
182 "Return the list window of the newsticker treeview."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
183 (nth 1 newsticker--treeview-windows))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
184 (defsubst newsticker--treeview-item-window ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
185 "Return the item window of the newsticker treeview."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
186 (nth 2 newsticker--treeview-windows))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
187
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
188 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
189 ;;; utility functions
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
190 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
191 (defun newsticker--treeview-get-id (parent i)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
192 "Create an id for a newsticker treeview node.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
193 PARENT is the node's parent, I is an integer."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
194 ;;(message "newsticker--treeview-get-id %s"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
195 ;; (format "%s-%d" (widget-get parent :nt-id) i))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
196 (format "%s-%d" (widget-get parent :nt-id) i))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
197
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
198 (defun newsticker--treeview-ids-eq (id1 id2)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
199 "Return non-nil if ids ID1 and ID2 are equal."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
200 ;;(message "%s/%s" (or id1 -1) (or id2 -1))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
201 (and id1 id2 (string= id1 id2)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
202
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
203 (defun newsticker--treeview-nodes-eq (node1 node2)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
204 "Compare treeview nodes NODE1 and NODE2 for equality.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
205 Nodes are equal if the have the same newsticker-id. Note that
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
206 during re-tagging and collapsing/expanding nodes change, while
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
207 their id stays constant."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
208 (let ((id1 (widget-get node1 :nt-id))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
209 (id2 (widget-get node2 :nt-id)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
210 ;;(message "%s/%s %s/%s" (widget-get node1 :tag) (widget-get node2 :tag)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
211 ;; (or id1 -1) (or id2 -1))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
212 (or (newsticker--treeview-ids-eq id1 id2)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
213 (string= (widget-get node1 :tag) (widget-get node2 :tag)))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
214
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
215 (defun newsticker--treeview-do-get-node-of-feed (feed-name startnode)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
216 "Recursivly search node for feed FEED-NAME starting from STARTNODE."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
217 ;;(message "%s/%s" feed-name (widget-get startnode :nt-feed))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
218 (if (string= feed-name (or (widget-get startnode :nt-feed)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
219 (widget-get startnode :nt-vfeed)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
220 (throw 'found startnode)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
221 (let ((children (widget-get startnode :children)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
222 (dolist (w children)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
223 (newsticker--treeview-do-get-node-of-feed feed-name w)))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
224
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
225 (defun newsticker--treeview-get-node-of-feed (feed-name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
226 "Return node for feed FEED-NAME in newsticker treeview tree."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
227 (catch 'found
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
228 (newsticker--treeview-do-get-node-of-feed feed-name
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
229 newsticker--treeview-feed-tree)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
230 (newsticker--treeview-do-get-node-of-feed feed-name
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
231 newsticker--treeview-vfeed-tree)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
232
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
233 (defun newsticker--treeview-do-get-node (id startnode)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
234 "Recursivly search node with ID starting from STARTNODE."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
235 (if (newsticker--treeview-ids-eq id (widget-get startnode :nt-id))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
236 (throw 'found startnode)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
237 (let ((children (widget-get startnode :children)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
238 (dolist (w children)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
239 (newsticker--treeview-do-get-node id w)))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
240
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
241 (defun newsticker--treeview-get-node (id)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
242 "Return node with ID in newsticker treeview tree."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
243 (catch 'found
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
244 (newsticker--treeview-do-get-node id newsticker--treeview-feed-tree)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
245 (newsticker--treeview-do-get-node id newsticker--treeview-vfeed-tree)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
246
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
247 (defun newsticker--treeview-get-current-node ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
248 "Return current node in newsticker treeview tree."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
249 (newsticker--treeview-get-node newsticker--treeview-current-node-id))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
250
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
251 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
252
95753
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
253 (declare-function w3m-toggle-inline-images "ext:w3m" (&optional force no-cache))
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
254
95679
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
255 (defun newsticker--treeview-render-text (start end)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
256 "Render text between markers START and END."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
257 (if newsticker-html-renderer
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
258 (condition-case error-data
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
259 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
260 (set-marker-insertion-type end t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
261 ;; check whether it is necessary to call html renderer
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
262 ;; (regexp inspired by htmlr.el)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
263 (goto-char start)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
264 (when (re-search-forward
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
265 "</?[A-Za-z1-6]*\\|&#?[A-Za-z0-9]+;" end t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
266 ;; (message "%s" (newsticker--title item))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
267 (let ((w3m-fill-column (if newsticker-use-full-width
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
268 -1 fill-column))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
269 (w3-maximum-line-length
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
270 (if newsticker-use-full-width nil fill-column)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
271 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
272 (funcall newsticker-html-renderer start end)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
273 ;;(cond ((eq newsticker-html-renderer 'w3m-region)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
274 ;; (add-text-properties start end (list 'keymap
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
275 ;; w3m-minor-mode-map)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
276 ;;((eq newsticker-html-renderer 'w3-region)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
277 ;;(add-text-properties start end (list 'keymap w3-mode-map))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
278 (if (eq newsticker-html-renderer 'w3m-region)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
279 (w3m-toggle-inline-images t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
280 t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
281 (error
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
282 (message "Error: HTML rendering failed: %s, %s"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
283 (car error-data) (cdr error-data))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
284 nil))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
285 nil))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
286
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
287 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
288 ;;; List window
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
289 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
290 (defun newsticker--treeview-list-add-item (item feed &optional show-feed)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
291 "Add news ITEM for FEED to newsticker treeview list window.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
292 If string SHOW-FEED is non-nil it is shown in the item string."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
293 (setq newsticker--treeview-list-show-feed show-feed)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
294 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
295 (set-buffer (newsticker--treeview-list-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
296 (let* ((inhibit-read-only t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
297 pos1 pos2)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
298 (goto-char (point-max))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
299 (setq pos1 (point-marker))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
300 (insert " ")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
301 (insert (propertize " " 'display '(space :align-to 2)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
302 (insert (if show-feed
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
303 (concat
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
304 (substring
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
305 (format "%-10s" (newsticker--real-feed-name
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
306 feed))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
307 0 10)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
308 (propertize " " 'display '(space :align-to 12)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
309 ""))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
310 (insert (format-time-string "%d.%m.%y, %H:%M"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
311 (newsticker--time item)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
312 (insert (propertize " " 'display
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
313 (list 'space :align-to (if show-feed 28 18))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
314 (setq pos2 (point-marker))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
315 (insert (newsticker--title item))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
316 (insert "\n")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
317 (newsticker--treeview-render-text pos2 (point-marker))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
318 (goto-char pos2)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
319 (while (search-forward "\n" nil t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
320 (replace-match " "))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
321 (let ((map (make-sparse-keymap)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
322 (define-key map [mouse-1] 'newsticker-treeview-tree-click)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
323 (define-key map "\n" 'newsticker-treeview-show-item)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
324 (define-key map "\C-m" 'newsticker-treeview-show-item)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
325 (add-text-properties pos1 (point-max)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
326 (list :nt-item item
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
327 :nt-feed feed
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
328 :nt-link (newsticker--link item)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
329 'mouse-face 'highlight
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
330 'keymap map
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
331 'help-echo "Show item")))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
332 (insert "\n"))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
333
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
334 (defun newsticker--treeview-list-clear ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
335 "Clear the newsticker treeview list window."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
336 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
337 (set-buffer (newsticker--treeview-list-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
338 (let ((inhibit-read-only t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
339 (erase-buffer)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
340 (kill-all-local-variables)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
341 (remove-overlays))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
342
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
343 (defun newsticker--treeview-list-items-with-age-callback (widget
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
344 changed-widget
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
345 &rest ages)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
346 "Fill newsticker treeview list window with items of certain age.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
347 This is a callback function for the treeview nodes.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
348 Argument WIDGET is the calling treeview widget.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
349 Argument CHANGED-WIDGET is the widget that actually has changed.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
350 Optional argument AGES is the list of ages that are to be shown."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
351 (newsticker--treeview-list-clear)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
352 (widget-put widget :nt-selected t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
353 (apply 'newsticker--treeview-list-items-with-age ages))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
354
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
355 (defun newsticker--treeview-list-items-with-age (&rest ages)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
356 "Actually fill newsticker treeview list window with items of certain age.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
357 AGES is the list of ages that are to be shown."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
358 (mapc (lambda (feed)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
359 (let ((feed-name-symbol (intern (car feed))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
360 (mapc (lambda (item)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
361 (when (memq (newsticker--age item) ages)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
362 (newsticker--treeview-list-add-item
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
363 item feed-name-symbol t)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
364 (newsticker--treeview-list-sort-items
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
365 (cdr (newsticker--cache-get-feed feed-name-symbol))))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
366 (append newsticker-url-list-defaults newsticker-url-list))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
367 (newsticker--treeview-list-update nil))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
368
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
369 (defun newsticker--treeview-list-new-items (widget changed-widget
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
370 &optional event)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
371 "Fill newsticker treeview list window with new items.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
372 This is a callback function for the treeview nodes.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
373 Argument WIDGET FIXME.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
374 Argument CHANGED-WIDGET FIXME.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
375 Optional argument EVENT FIXME."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
376 (newsticker--treeview-list-items-with-age-callback widget changed-widget
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
377 'new)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
378 (newsticker--treeview-item-show-text
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
379 "New items"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
380 "This is a virtual feed containing all new items"))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
381
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
382 (defun newsticker--treeview-list-immortal-items (widget changed-widget
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
383 &optional event)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
384 "Fill newsticker treeview list window with immortal items.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
385 This is a callback function for the treeview nodes.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
386 Argument WIDGET FIXME.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
387 Argument CHANGED-WIDGET FIXME.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
388 Optional argument EVENT FIXME."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
389 (newsticker--treeview-list-items-with-age-callback widget changed-widget
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
390 'immortal)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
391 (newsticker--treeview-item-show-text
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
392 "Immortal items"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
393 "This is a virtual feed containing all immortal items."))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
394
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
395 (defun newsticker--treeview-list-obsolete-items (widget changed-widget
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
396 &optional event)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
397 "Fill newsticker treeview list window with obsolete items.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
398 This is a callback function for the treeview nodes.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
399 Argument WIDGET FIXME.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
400 Argument CHANGED-WIDGET FIXME.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
401 Optional argument EVENT FIXME."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
402 (newsticker--treeview-list-items-with-age-callback widget changed-widget
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
403 'obsolete)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
404 (newsticker--treeview-item-show-text
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
405 "Obsolete items"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
406 "This is a virtual feed containing all obsolete items."))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
407
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
408 (defun newsticker--treeview-list-all-items (widget changed-widget
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
409 &optional event)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
410 "Fill newsticker treeview list window with all items.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
411 This is a callback function for the treeview nodes.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
412 Argument WIDGET FIXME.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
413 Argument CHANGED-WIDGET FIXME.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
414 Optional argument EVENT FIXME."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
415 (newsticker--treeview-list-items-with-age-callback widget changed-widget
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
416 event 'new 'old
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
417 'obsolete 'immortal)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
418 (newsticker--treeview-item-show-text
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
419 "All items"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
420 "This is a virtual feed containing all items."))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
421
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
422 (defun newsticker--treeview-list-items-v (vfeed-name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
423 "List items for virtual feed VFEED-NAME."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
424 (when vfeed-name
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
425 (cond ((string-match "\\*new\\*" vfeed-name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
426 (newsticker--treeview-list-items-with-age 'new))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
427 ((string-match "\\*immortal\\*" vfeed-name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
428 (newsticker--treeview-list-items-with-age 'immortal))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
429 ((string-match "\\*old\\*" vfeed-name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
430 (newsticker--treeview-list-items-with-age 'old nil)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
431 (newsticker--treeview-list-update nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
432 ))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
433
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
434 (defun newsticker--treeview-list-items (feed-name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
435 "List items for feed FEED-NAME."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
436 (when feed-name
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
437 (if (newsticker--treeview-virtual-feed-p feed-name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
438 (newsticker--treeview-list-items-v feed-name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
439 (mapc (lambda (item)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
440 (if (eq (newsticker--age item) 'feed)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
441 (newsticker--treeview-item-show item (intern feed-name))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
442 (newsticker--treeview-list-add-item item
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
443 (intern feed-name))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
444 (newsticker--treeview-list-sort-items
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
445 (cdr (newsticker--cache-get-feed (intern feed-name)))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
446 (newsticker--treeview-list-update nil))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
447
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
448 (defun newsticker--treeview-list-feed-items (widget changed-widget
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
449 &optional event)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
450 "Callback function for listing feed items.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
451 Argument WIDGET FIXME.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
452 Argument CHANGED-WIDGET FIXME.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
453 Optional argument EVENT FIXME."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
454 (newsticker--treeview-list-clear)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
455 (widget-put widget :nt-selected t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
456 (let ((feed-name (widget-get widget :nt-feed))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
457 (vfeed-name (widget-get widget :nt-vfeed)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
458 (if feed-name
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
459 (newsticker--treeview-list-items feed-name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
460 (newsticker--treeview-list-items-v vfeed-name))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
461
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
462 (defun newsticker--treeview-list-compare-item-by-age (item1 item2)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
463 "Compare two news items ITEM1 and ITEM2 wrt age."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
464 (catch 'result
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
465 (let ((age1 (newsticker--age item1))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
466 (age2 (newsticker--age item2)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
467 (cond ((eq age1 'new)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
468 t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
469 ((eq age1 'immortal)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
470 (cond ((eq age2 'new)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
471 t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
472 ((eq age2 'immortal)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
473 t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
474 (t
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
475 nil)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
476 ((eq age1 'old)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
477 (cond ((eq age2 'new)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
478 nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
479 ((eq age2 'immortal)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
480 nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
481 ((eq age2 'old)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
482 nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
483 (t
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
484 t)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
485 (t
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
486 nil)))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
487
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
488 (defun newsticker--treeview-list-compare-item-by-age-reverse (item1 item2)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
489 "Compare two news items ITEM1 and ITEM2 wrt age in reverse order."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
490 (newsticker--treeview-list-compare-item-by-age item2 item1))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
491
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
492 (defun newsticker--treeview-list-compare-item-by-time (item1 item2)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
493 "Compare two news items ITEM1 and ITEM2 wrt time values."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
494 (newsticker--cache-item-compare-by-time item1 item2))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
495
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
496 (defun newsticker--treeview-list-compare-item-by-time-reverse (item1 item2)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
497 "Compare two news items ITEM1 and ITEM2 wrt time values in reverse order."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
498 (newsticker--cache-item-compare-by-time item2 item1))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
499
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
500 (defun newsticker--treeview-list-compare-item-by-title (item1 item2)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
501 "Compare two news items ITEM1 and ITEM2 wrt title."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
502 (newsticker--cache-item-compare-by-title item1 item2))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
503
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
504 (defun newsticker--treeview-list-compare-item-by-title-reverse (item1 item2)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
505 "Compare two news items ITEM1 and ITEM2 wrt title in reverse order."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
506 (newsticker--cache-item-compare-by-title item2 item1))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
507
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
508 (defun newsticker--treeview-list-sort-items (items)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
509 "Return sorted copy of list ITEMS.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
510 The sort function is chosen according to the value of
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
511 `newsticker--treeview-list-sort-order'."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
512 (let ((sort-fun
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
513 (cond ((eq newsticker--treeview-list-sort-order 'sort-by-age)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
514 'newsticker--treeview-list-compare-item-by-age)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
515 ((eq newsticker--treeview-list-sort-order
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
516 'sort-by-age-reverse)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
517 'newsticker--treeview-list-compare-item-by-age-reverse)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
518 ((eq newsticker--treeview-list-sort-order 'sort-by-time)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
519 'newsticker--treeview-list-compare-item-by-time)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
520 ((eq newsticker--treeview-list-sort-order
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
521 'sort-by-time-reverse)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
522 'newsticker--treeview-list-compare-item-by-time-reverse)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
523 ((eq newsticker--treeview-list-sort-order 'sort-by-title)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
524 'newsticker--treeview-list-compare-item-by-title)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
525 ((eq newsticker--treeview-list-sort-order
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
526 'sort-by-title-reverse)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
527 'newsticker--treeview-list-compare-item-by-title-reverse)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
528 (t
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
529 'newsticker--treeview-list-compare-item-by-title))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
530 (sort (copy-sequence items) sort-fun)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
531
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
532 (defun newsticker--treeview-list-update-faces ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
533 "Update faces in the treeview list buffer."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
534 (let (pos-sel)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
535 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
536 (set-buffer (newsticker--treeview-list-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
537 (let ((inhibit-read-only t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
538 (goto-char (point-min))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
539 (while (not (eobp))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
540 (let* ((pos (save-excursion (end-of-line) (point)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
541 (item (get-text-property (point) :nt-item))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
542 (age (newsticker--age item))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
543 (selected (get-text-property (point) :nt-selected))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
544 (face (cond ((eq age 'new)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
545 'newsticker-treeview-new-face)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
546 ((eq age 'old)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
547 'newsticker-treeview-old-face)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
548 ((eq age 'immortal)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
549 'newsticker-treeview-immortal-face)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
550 ((eq age 'obsolete)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
551 'newsticker-treeview-obsolete-face)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
552 (t
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
553 'bold))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
554 (put-text-property (point) pos 'face face)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
555 (if selected
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
556 (move-overlay newsticker--selection-overlay (point)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
557 (1+ pos) ;include newline
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
558 (current-buffer)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
559 (if selected (setq pos-sel (point)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
560 (forward-line 1)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
561 (beginning-of-line))))) ;; FIXME!?
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
562 (when pos-sel
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
563 (set-window-point (newsticker--treeview-list-window) pos-sel))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
564
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
565 (defun newsticker--treeview-list-clear-highlight ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
566 "Clear the highlight in the treeview list buffer."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
567 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
568 (set-buffer (newsticker--treeview-list-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
569 (let ((inhibit-read-only t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
570 (put-text-property (point-min) (point-max) :nt-selected nil))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
571 (newsticker--treeview-list-update-faces)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
572
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
573 (defun newsticker--treeview-list-update-highlight ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
574 "Update the highlight in the treeview list buffer."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
575 (newsticker--treeview-list-clear-highlight)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
576 (let (pos num-lines)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
577 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
578 (set-buffer (newsticker--treeview-list-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
579 (let ((inhibit-read-only t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
580 (put-text-property (save-excursion (beginning-of-line) (point))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
581 (save-excursion (end-of-line) (point))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
582 :nt-selected t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
583 (newsticker--treeview-list-update-faces))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
584
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
585 (defun newsticker--treeview-list-highlight-start ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
586 "Return position of selection in treeview list buffer."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
587 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
588 (set-buffer (newsticker--treeview-list-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
589 (goto-char (point-min))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
590 (next-single-property-change (point) :nt-selected)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
591
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
592 (defun newsticker--treeview-list-update (clear-buffer)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
593 "Update the faces and highlight in the treeview list buffer.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
594 If CLEAR-BUFFER is non-nil the list buffer is completely erased."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
595 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
596 (set-window-buffer (newsticker--treeview-list-window)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
597 (newsticker--treeview-list-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
598 (if newsticker-treeview-own-frame
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
599 (set-window-dedicated-p (newsticker--treeview-list-window) t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
600 (set-buffer (newsticker--treeview-list-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
601 (if clear-buffer
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
602 (let ((inhibit-read-only t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
603 (erase-buffer)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
604 (newsticker-treeview-list-mode)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
605 (newsticker--treeview-list-update-faces)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
606 (goto-char (point-min))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
607
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
608 ;;(makunbound 'newsticker-treeview-list-sort-button-map);; FIXME
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
609 (defvar newsticker-treeview-list-sort-button-map
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
610 (let ((map (make-sparse-keymap)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
611 (define-key map [header-line mouse-1]
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
612 'newsticker--treeview-list-sort-by-column)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
613 (define-key map [header-line mouse-2]
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
614 'newsticker--treeview-list-sort-by-column)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
615 map)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
616 "Local keymap for newsticker treeview list window sort buttons.")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
617
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
618 (defun newsticker--treeview-list-sort-by-column (&optional e)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
619 "Sort the newsticker list window buffer by the column clicked on.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
620 Optional argument E FIXME."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
621 (interactive (list last-input-event))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
622 (if e (mouse-select-window e))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
623 (let* ((pos (event-start e))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
624 (obj (posn-object pos))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
625 (sort-order (if obj
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
626 (get-text-property (cdr obj) 'sort-order (car obj))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
627 (get-text-property (posn-point pos) 'sort-order))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
628 (setq newsticker--treeview-list-sort-order
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
629 (cond ((eq sort-order 'sort-by-age)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
630 (if (eq newsticker--treeview-list-sort-order 'sort-by-age)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
631 'sort-by-age-reverse
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
632 'sort-by-age))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
633 ((eq sort-order 'sort-by-time)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
634 (if (eq newsticker--treeview-list-sort-order 'sort-by-time)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
635 'sort-by-time-reverse
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
636 'sort-by-time))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
637 ((eq sort-order 'sort-by-title)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
638 (if (eq newsticker--treeview-list-sort-order 'sort-by-title)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
639 'sort-by-title-reverse
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
640 'sort-by-title))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
641 (newsticker-treeview-update)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
642
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
643 (defun newsticker-treeview-list-make-sort-button (name sort-order)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
644 "Create propertized string for headerline button.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
645 NAME is the button text, SORT-ORDER is the associated sort order
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
646 for the button."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
647 (let ((face (if (string-match (symbol-name sort-order)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
648 (symbol-name
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
649 newsticker--treeview-list-sort-order))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
650 'bold
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
651 'header-line)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
652 (propertize name
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
653 'sort-order sort-order
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
654 'help-echo (concat "Sort by " name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
655 'mouse-face 'highlight
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
656 'face face
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
657 'keymap newsticker-treeview-list-sort-button-map)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
658
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
659 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
660 ;;; item window
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
661 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
662 (defun newsticker--treeview-item-show-text (title description)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
663 "Show text in treeview item buffer consisting of TITLE and DESCRIPTION."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
664 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
665 (set-buffer (newsticker--treeview-item-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
666 (when (fboundp 'w3m-process-stop)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
667 (w3m-process-stop (current-buffer)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
668 (let ((inhibit-read-only t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
669 (erase-buffer)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
670 (kill-all-local-variables)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
671 (remove-overlays)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
672 (insert title)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
673 (put-text-property (point-min) (point) 'face 'newsticker-feed-face)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
674 (insert "\n\n" description)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
675 (when newsticker-justification
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
676 (fill-region (point-min) (point-max) newsticker-justification))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
677 (newsticker-treeview-mode)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
678 (goto-char (point-min)))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
679
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
680 (defun newsticker--treeview-item-show (item feed)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
681 "Show news ITEM coming from FEED in treeview item buffer."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
682 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
683 (set-buffer (newsticker--treeview-item-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
684 (when (fboundp 'w3m-process-stop)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
685 (w3m-process-stop (current-buffer)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
686 (let ((inhibit-read-only t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
687 (is-rendered-HTML nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
688 pos
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
689 (marker1 (make-marker))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
690 (marker2 (make-marker)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
691 (erase-buffer)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
692 (kill-all-local-variables)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
693 (remove-overlays)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
694
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
695 (when (and item feed)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
696 (let ((wwidth (1- (window-width (newsticker--treeview-item-window)))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
697 (if newsticker-use-full-width
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
698 (set (make-local-variable 'fill-column) wwidth))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
699 (set (make-local-variable 'fill-column) (min fill-column
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
700 wwidth)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
701 (let ((desc (newsticker--desc item)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
702 (insert "\n" (or desc "[No Description]")))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
703 (set-marker marker1 (1+ (point-min)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
704 (set-marker marker2 (point-max))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
705 (setq is-rendered-HTML (newsticker--treeview-render-text marker1
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
706 marker2))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
707 (when (and newsticker-justification
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
708 (not is-rendered-HTML))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
709 (fill-region marker1 marker2 newsticker-justification))
95760
e62f5d3e9fad Remove trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 95753
diff changeset
710
95679
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
711 (newsticker-treeview-mode)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
712 (goto-char (point-min))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
713 ;; insert logo at top
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
714 (let* ((newsticker-enable-logo-manipulations nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
715 (img (newsticker--image-read feed nil)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
716 (if (and (display-images-p) img)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
717 (newsticker--insert-image img (car item))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
718 (insert (newsticker--real-feed-name feed))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
719 (add-text-properties (point-min) (point)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
720 (list 'face 'newsticker-feed-face
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
721 'mouse-face 'highlight
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
722 'help-echo "Visit in web browser."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
723 :nt-link (newsticker--link item)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
724 'keymap newsticker--treeview-url-keymap))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
725 (setq pos (point))
95760
e62f5d3e9fad Remove trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 95753
diff changeset
726
95679
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
727 (insert "\n\n")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
728 ;; insert title
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
729 (setq pos (point))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
730 (insert (newsticker--title item) "\n")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
731 (set-marker marker1 pos)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
732 (set-marker marker2 (point))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
733 (newsticker--treeview-render-text marker1 marker2)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
734 (put-text-property pos (point) 'face 'newsticker-treeview-new-face)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
735 (goto-char marker2)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
736 (delete-char -1)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
737 (insert "\n")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
738 (put-text-property marker2 (point) 'face 'newsticker-treeview-face)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
739 (set-marker marker2 (point))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
740 (when newsticker-justification
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
741 (fill-region marker1 marker2 newsticker-justification))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
742 (goto-char marker2)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
743 (add-text-properties marker1 (1- (point))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
744 (list 'mouse-face 'highlight
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
745 'help-echo "Visit in web browser."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
746 :nt-link (newsticker--link item)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
747 'keymap newsticker--treeview-url-keymap))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
748 (insert (format-time-string newsticker-date-format
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
749 (newsticker--time item)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
750 (insert "\n")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
751 (setq pos (point))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
752 (insert "\n")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
753 ;; insert enclosures and rest at bottom
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
754 (goto-char (point-max))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
755 (insert "\n\n")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
756 (setq pos (point))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
757 (newsticker--insert-enclosure item newsticker--treeview-url-keymap)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
758 (put-text-property pos (point) 'face 'newsticker-enclosure-face)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
759 (setq pos (point))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
760 (insert "\n")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
761 (newsticker--print-extra-elements item newsticker--treeview-url-keymap)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
762 (put-text-property pos (point) 'face 'newsticker-extra-face)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
763 (goto-char (point-min)))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
764 (if (and newsticker-treeview-automatically-mark-displayed-items-as-old
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
765 item
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
766 (memq (newsticker--age item) '(new obsolete)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
767 (let ((newsticker-treeview-automatically-mark-displayed-items-as-old nil))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
768 (newsticker-treeview-mark-item-old t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
769 (newsticker--treeview-list-update-faces)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
770 (set-window-point (newsticker--treeview-item-window) 1))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
771
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
772 (defun newsticker--treeview-item-update ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
773 "Update the treeview item buffer and window."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
774 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
775 (set-window-buffer (newsticker--treeview-item-window)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
776 (newsticker--treeview-item-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
777 (if newsticker-treeview-own-frame
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
778 (set-window-dedicated-p (newsticker--treeview-item-window) t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
779 (set-buffer (newsticker--treeview-item-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
780 (let ((inhibit-read-only t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
781 (erase-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
782 (newsticker-treeview-mode)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
783
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
784 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
785 ;;; Tree window
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
786 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
787 (defun newsticker--treeview-tree-expand (tree)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
788 "Expand TREE.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
789 Callback function for tree widget that adds nodes for feeds and subgroups."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
790 (newsticker--group-manage-orphan-feeds)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
791 (tree-widget-set-theme "folder")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
792 (let ((group (widget-get tree :nt-group))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
793 (i 0)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
794 (nt-id ""))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
795 (mapcar (lambda (g)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
796 (setq nt-id (newsticker--treeview-get-id tree i))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
797 (setq i (1+ i))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
798 (if (listp g)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
799 (let* ((g-name (car g)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
800 `(tree-widget
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
801 :tag ,(newsticker--treeview-tree-get-tag g-name nil nt-id)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
802 :expander newsticker--treeview-tree-expand
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
803 :expander-p (lambda (&rest ignore) t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
804 :nt-group ,(cdr g)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
805 :nt-feed ,g-name
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
806 :nt-id ,nt-id
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
807 :keep (:nt-feed :num-new :nt-id :open);; :nt-group
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
808 :open nil))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
809 (let ((tag (newsticker--treeview-tree-get-tag g nil nt-id)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
810 `(item :tag ,tag
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
811 :leaf-icon newsticker--tree-widget-leaf-icon
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
812 :nt-feed ,g
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
813 :action newsticker--treeview-list-feed-items
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
814 :nt-id ,nt-id
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
815 :keep (:nt-id)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
816 :open t))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
817 group)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
818
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
819 (defun newsticker--treeview-tree-expand-status (tree &optional changed-widget
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
820 event)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
821 "Expand the vfeed TREE.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
822 Optional arguments CHANGED-WIDGET and EVENT are ignored."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
823 (tree-widget-set-theme "folder")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
824 (list `(item :tag ,(newsticker--treeview-tree-get-tag nil "new")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
825 :nt-vfeed "new"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
826 :action newsticker--treeview-list-new-items
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
827 :nt-id ,(newsticker--treeview-get-id tree 0)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
828 :keep (:nt-id))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
829 `(item :tag ,(newsticker--treeview-tree-get-tag nil "immortal")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
830 :nt-vfeed "immortal"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
831 :action newsticker--treeview-list-immortal-items
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
832 :nt-id ,(newsticker--treeview-get-id tree 1)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
833 :keep (:nt-id))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
834 `(item :tag ,(newsticker--treeview-tree-get-tag nil "obsolete")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
835 :nt-vfeed "obsolete"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
836 :action newsticker--treeview-list-obsolete-items
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
837 :nt-id ,(newsticker--treeview-get-id tree 2)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
838 :keep (:nt-id))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
839 `(item :tag ,(newsticker--treeview-tree-get-tag nil "all")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
840 :nt-vfeed "all"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
841 :action newsticker--treeview-list-all-items
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
842 :nt-id ,(newsticker--treeview-get-id tree 3)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
843 :keep (:nt-id))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
844
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
845 (defun newsticker--treeview-virtual-feed-p (feed-name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
846 "Return non-nil if FEED-NAME is a virtual feed."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
847 (string-match "\\*.*\\*" feed-name))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
848
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
849 (define-widget 'newsticker--tree-widget-leaf-icon 'tree-widget-icon
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
850 "Icon for a tree-widget leaf node."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
851 :tag "O"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
852 :glyph-name "leaf"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
853 :button-face 'default)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
854
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
855 (defun newsticker--treeview-tree-update ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
856 "Update treeview tree buffer and window."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
857 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
858 (set-window-buffer (newsticker--treeview-tree-window)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
859 (newsticker--treeview-tree-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
860 (if newsticker-treeview-own-frame
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
861 (set-window-dedicated-p (newsticker--treeview-tree-window) t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
862 (set-buffer (newsticker--treeview-tree-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
863 (kill-all-local-variables)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
864 (let ((inhibit-read-only t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
865 (erase-buffer)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
866 (tree-widget-set-theme "folder")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
867 (setq newsticker--treeview-feed-tree
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
868 (widget-create 'tree-widget
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
869 :tag (newsticker--treeview-propertize-tag
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
870 "Feeds" 0 "feeds")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
871 :expander 'newsticker--treeview-tree-expand
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
872 :expander-p (lambda (&rest ignore) t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
873 :leaf-icon 'newsticker--tree-widget-leaf-icon
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
874 :nt-group (cdr newsticker-groups)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
875 :nt-id "feeds"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
876 :keep '(:nt-id)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
877 :open t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
878 (setq newsticker--treeview-vfeed-tree
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
879 (widget-create 'tree-widget
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
880 :tag (newsticker--treeview-propertize-tag
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
881 "Virtual Feeds" 0 "vfeeds")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
882 :expander 'newsticker--treeview-tree-expand-status
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
883 :expander-p (lambda (&rest ignore) t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
884 :leaf-icon 'newsticker--tree-widget-leaf-icon
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
885 :nt-id "vfeeds"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
886 :keep '(:nt-id)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
887 :open t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
888 (use-local-map widget-keymap)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
889 (widget-setup))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
890 (newsticker-treeview-mode)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
891
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
892 (defun newsticker--treeview-propertize-tag (tag &optional num-new nt-id feed
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
893 vfeed)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
894 "Return propertized copy of string TAG.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
895 Optional argument NUM-NEW is used for choosing face, other
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
896 arguments NT-ID, FEED, and VFEED are added as properties."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
897 ;;(message "newsticker--treeview-propertize-tag '%s' %s" feed nt-id)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
898 (let ((face 'newsticker-treeview-face)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
899 (map (make-sparse-keymap)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
900 (if (and num-new (> num-new 0))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
901 (setq face 'newsticker-treeview-new-face))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
902 (define-key map [mouse-1] 'newsticker-treeview-tree-click)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
903 (define-key map "\n" 'newsticker-treeview-tree-do-click)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
904 (define-key map "\C-m" 'newsticker-treeview-tree-do-click)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
905 (propertize tag 'face face 'keymap map
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
906 :nt-id nt-id
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
907 :nt-feed feed
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
908 :nt-vfeed vfeed
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
909 'help-echo "Clickme!"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
910 'mouse-face 'highlight)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
911
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
912 (defun newsticker--treeview-tree-get-tag (feed-name vfeed-name
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
913 &optional nt-id)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
914 "Return a tag string for either FEED-NAME or, if it is nil, for VFEED-NAME.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
915 Optional argument NT-ID is added to the tag's properties."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
916 (let (tag (num-new 0))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
917 (cond (vfeed-name
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
918 (cond ((string= vfeed-name "new")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
919 (setq num-new (newsticker--stat-num-items-total 'new))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
920 (setq tag (format "New items (%d)" num-new)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
921 ((string= vfeed-name "immortal")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
922 (setq num-new (newsticker--stat-num-items-total 'immortal))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
923 (setq tag (format "Immortal items (%d)" num-new)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
924 ((string= vfeed-name "obsolete")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
925 (setq num-new (newsticker--stat-num-items-total 'obsolete))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
926 (setq tag (format "Obsolete items (%d)" num-new)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
927 ((string= vfeed-name "all")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
928 (setq num-new (newsticker--stat-num-items-total))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
929 (setq tag (format "All items (%d)" num-new)))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
930 (feed-name
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
931 (setq num-new (newsticker--stat-num-items-for-group
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
932 (intern feed-name) 'new 'immortal))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
933 (setq tag
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
934 (format "%s (%d)"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
935 (newsticker--real-feed-name (intern feed-name))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
936 num-new))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
937 (if tag
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
938 (newsticker--treeview-propertize-tag tag num-new
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
939 nt-id
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
940 feed-name vfeed-name))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
941
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
942 (defun newsticker--stat-num-items-for-group (feed-name-symbol &rest ages)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
943 "Count number of items in feed FEED-NAME-SYMBOL that have an age matching AGES."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
944 ;;(message "newsticker--stat-num-items-for-group %s %s" feed-name-symbol ages)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
945 (let ((result (apply 'newsticker--stat-num-items feed-name-symbol ages)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
946 (mapc (lambda (f-n)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
947 (setq result (+ result
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
948 (apply 'newsticker--stat-num-items (intern f-n)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
949 ages))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
950 (newsticker--group-get-feeds
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
951 (newsticker--group-get-group (symbol-name feed-name-symbol)) t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
952 result))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
953
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
954 (defun newsticker--treeview-count-node-items (feed &optional isvirtual)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
955 "Count number of relevant items for a treeview node.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
956 FEED gives the name of the feed or group. If ISVIRTUAL is non-nil
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
957 the feed is a virtual feed."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
958 (let* ((num-new 0))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
959 (if feed
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
960 (if isvirtual
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
961 (cond ((string= feed "new")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
962 (setq num-new (newsticker--stat-num-items-total 'new)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
963 ((string= feed "immortal")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
964 (setq num-new (newsticker--stat-num-items-total 'immortal)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
965 ((string= feed "obsolete")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
966 (setq num-new (newsticker--stat-num-items-total 'obsolete)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
967 ((string= feed "all")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
968 (setq num-new (newsticker--stat-num-items-total))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
969 (setq num-new (newsticker--stat-num-items-for-group
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
970 (intern feed) 'new 'immortal))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
971 num-new))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
972
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
973 (defun newsticker--treeview-tree-update-tag (w &optional recursive
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
974 &rest ignore)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
975 "Update tag for tree widget W.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
976 If RECURSIVE is non-nil recursively update parent widgets as
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
977 well. Argument IGNORE is ignored. Note that this function, if
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
978 called recursively, makes w invalid. You should keep w's nt-id in
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
979 that case."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
980 ;;(message "newsticker--treeview-tree-update-tag %s, %s" (widget-get w :tag)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
981 ;; (widget-type w))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
982 (let* ((parent (widget-get w :parent))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
983 (feed (or (widget-get w :nt-feed) (widget-get parent :nt-feed)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
984 (vfeed (or (widget-get w :nt-vfeed) (widget-get parent :nt-vfeed)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
985 (nt-id (or (widget-get w :nt-id) (widget-get parent :nt-id)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
986 (num-new (newsticker--treeview-count-node-items (or feed vfeed)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
987 vfeed))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
988 (tag (newsticker--treeview-tree-get-tag feed vfeed nt-id))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
989 (n (widget-get w :node)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
990 (if parent
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
991 (if recursive
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
992 (newsticker--treeview-tree-update-tag parent)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
993 (when tag
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
994 (when n
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
995 (widget-put n :tag tag))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
996 (widget-put w :num-new num-new)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
997 (widget-put w :tag tag)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
998 (when (marker-position (widget-get w :from))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
999 (let ((p (point))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1000 (notify (widget-get w :notify)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1001 ;; FIXME: This moves point!!!!
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1002 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1003 (set-buffer (newsticker--treeview-tree-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1004 (widget-value-set w (widget-value w)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1005 (goto-char p))))))
95753
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1006
95679
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1007 (defun newsticker--treeview-tree-do-update-tags (widget)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1008 "Actually recursively update tags for WIDGET."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1009 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1010 (let ((children (widget-get widget :children)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1011 (dolist (w children)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1012 (newsticker--treeview-tree-do-update-tags w))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1013 (newsticker--treeview-tree-update-tag widget))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1014
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1015 (defun newsticker--treeview-tree-update-tags (&rest ignore)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1016 "Update all tags of all trees.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1017 Arguments IGNORE are ignored."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1018 (save-current-buffer
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1019 (set-buffer (newsticker--treeview-tree-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1020 (let ((inhibit-read-only t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1021 (newsticker--treeview-tree-do-update-tags
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1022 newsticker--treeview-feed-tree)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1023 (newsticker--treeview-tree-do-update-tags
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1024 newsticker--treeview-vfeed-tree))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1025 (tree-widget-set-theme "folder")))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1026
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1027 (defun newsticker--treeview-tree-update-highlight ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1028 "Update highlight in tree buffer."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1029 (let ((pos (widget-get (newsticker--treeview-get-current-node) :from)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1030 (unless (or (integerp pos) (and (markerp pos) (marker-position pos)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1031 (setq pos (widget-get (widget-get
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1032 (newsticker--treeview-get-current-node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1033 :parent) :from)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1034 (when (or (integerp pos) (and (markerp pos) (marker-position pos)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1035 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1036 (set-buffer (newsticker--treeview-tree-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1037 (goto-char pos)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1038 (move-overlay newsticker--tree-selection-overlay
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1039 (save-excursion (beginning-of-line) (point))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1040 (save-excursion (end-of-line) (1+ (point)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1041 (current-buffer)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1042 (set-window-point (newsticker--treeview-tree-window) pos))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1043
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1044 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1045 ;;; Toolbar
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1046 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1047 ;;(makunbound 'newsticker-treeview-tool-bar-map)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1048 (defvar newsticker-treeview-tool-bar-map
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1049 (if (featurep 'xemacs)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1050 nil
95753
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1051 (if (boundp 'tool-bar-map)
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1052 (let ((tool-bar-map (make-sparse-keymap)))
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1053 (define-key tool-bar-map [newsticker-sep-1]
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1054 (list 'menu-item "--double-line"))
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1055 (define-key tool-bar-map [newsticker-browse-url]
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1056 (list 'menu-item "newsticker-browse-url"
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1057 'newsticker-browse-url
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1058 :visible t
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1059 :help "Browse URL for item at point"
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1060 :image newsticker--browse-image))
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1061 (define-key tool-bar-map [newsticker-buffer-force-update]
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1062 (list 'menu-item "newsticker-treeview-update"
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1063 'newsticker-treeview-update
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1064 :visible t
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1065 :help "Update newsticker buffer"
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1066 :image newsticker--update-image
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1067 :enable t))
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1068 (define-key tool-bar-map [newsticker-get-all-news]
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1069 (list 'menu-item "newsticker-get-all-news" 'newsticker-get-all-news
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1070 :visible t
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1071 :help "Get news for all feeds"
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1072 :image newsticker--get-all-image))
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1073 (define-key tool-bar-map [newsticker-mark-item-at-point-as-read]
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1074 (list 'menu-item "newsticker-treeview-mark-item-old"
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1075 'newsticker-treeview-mark-item-old
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1076 :visible t
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1077 :image newsticker--mark-read-image
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1078 :help "Mark current item as read"
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1079 ;;:enable '(newsticker-item-not-old-p) FIXME
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1080 ))
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1081 (define-key tool-bar-map [newsticker-mark-item-at-point-as-immortal]
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1082 (list 'menu-item "newsticker-treeview-toggle-item-immortal"
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1083 'newsticker-treeview-toggle-item-immortal
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1084 :visible t
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1085 :image newsticker--mark-immortal-image
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1086 :help "Toggle current item as immortal"
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1087 :enable t
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1088 ;;'(newsticker-item-not-immortal-p) FIXME
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1089 ))
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1090 (define-key tool-bar-map [newsticker-next-feed]
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1091 (list 'menu-item "newsticker-treeview-next-feed"
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1092 'newsticker-treeview-next-feed
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1093 :visible t
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1094 :help "Go to next feed"
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1095 :image newsticker--next-feed-image
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1096 :enable t
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1097 ;;'(newsticker-next-feed-available-p) FIXME
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1098 ))
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1099 (define-key tool-bar-map [newsticker-treeview-next-item]
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1100 (list 'menu-item "newsticker-treeview-next-item"
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1101 'newsticker-treeview-next-item
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1102 :visible t
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1103 :help "Go to next item"
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1104 :image newsticker--next-item-image
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1105 :enable t
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1106 ;;'(newsticker-next-item-available-p) FIXME
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1107 ))
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1108 (define-key tool-bar-map [newsticker-treeview-prev-item]
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1109 (list 'menu-item "newsticker-treeview-prev-item"
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1110 'newsticker-treeview-prev-item
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1111 :visible t
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1112 :help "Go to previous item"
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1113 :image newsticker--previous-item-image
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1114 :enable t
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1115 ;;'(newsticker-previous-item-available-p) FIXME
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1116 ))
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1117 (define-key tool-bar-map [newsticker-treeview-prev-feed]
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1118 (list 'menu-item "newsticker-treeview-prev-feed"
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1119 'newsticker-treeview-prev-feed
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1120 :visible t
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1121 :help "Go to previous feed"
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1122 :image newsticker--previous-feed-image
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1123 :enable t
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1124 ;;'(newsticker-previous-feed-available-p) FIXME
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1125 ))
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1126 ;; standard icons / actions
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1127 (tool-bar-add-item "close"
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1128 'newsticker-treeview-quit
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1129 'newsticker-treeview-quit
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1130 :help "Close newsticker")
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1131 (tool-bar-add-item "preferences"
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1132 'newsticker-customize
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1133 'newsticker-customize
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1134 :help "Customize newsticker")
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1135 tool-bar-map))))
95679
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1136
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1137 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1138 ;;; actions
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1139 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1140
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1141 (defun newsticker-treeview-mouse-browse-url (event)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1142 "Call `browse-url' for the link of the item at which the EVENT occurred."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1143 (interactive "e")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1144 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1145 (switch-to-buffer (window-buffer (posn-window (event-end event))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1146 (let ((url (get-text-property (posn-point (event-end event))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1147 :nt-link)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1148 (when url
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1149 (browse-url url)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1150 (if newsticker-automatically-mark-visited-items-as-old
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1151 (newsticker-treeview-mark-item-old))))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1152
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1153 (defun newsticker-treeview-browse-url ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1154 "Call `browse-url' for the link of the item at point."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1155 (interactive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1156 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1157 (set-buffer (newsticker--treeview-list-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1158 (let ((url (get-text-property (point) :nt-link)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1159 (when url
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1160 (browse-url url)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1161 (if newsticker-automatically-mark-visited-items-as-old
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1162 (newsticker-treeview-mark-item-old))))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1163
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1164 (defun newsticker--treeview-buffer-init ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1165 "Initialize all treeview buffers."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1166 (setq newsticker--treeview-buffers nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1167 (add-to-list 'newsticker--treeview-buffers
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1168 (get-buffer-create "*Newsticker Tree*") t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1169 (add-to-list 'newsticker--treeview-buffers
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1170 (get-buffer-create "*Newsticker List*") t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1171 (add-to-list 'newsticker--treeview-buffers
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1172 (get-buffer-create "*Newsticker Item*") t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1173
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1174 (unless newsticker--selection-overlay
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1175 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1176 (set-buffer (newsticker--treeview-list-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1177 (setq newsticker--selection-overlay (make-overlay (point-min)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1178 (point-max)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1179 (overlay-put newsticker--selection-overlay 'face
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1180 'newsticker-treeview-selection-face)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1181 (unless newsticker--tree-selection-overlay
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1182 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1183 (set-buffer (newsticker--treeview-tree-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1184 (setq newsticker--tree-selection-overlay (make-overlay (point-min)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1185 (point-max)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1186 (overlay-put newsticker--tree-selection-overlay 'face
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1187 'newsticker-treeview-selection-face)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1188
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1189 (newsticker--treeview-tree-update)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1190 (newsticker--treeview-list-update t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1191 (newsticker--treeview-item-update))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1192
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1193 (defun newsticker-treeview-update ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1194 "Update all treeview buffers and windows."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1195 (interactive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1196 (newsticker--cache-update)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1197 (newsticker--group-manage-orphan-feeds)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1198 (newsticker--treeview-list-update t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1199 (newsticker--treeview-item-update)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1200 (newsticker--treeview-tree-update-tags)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1201 (cond (newsticker--treeview-current-feed
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1202 (newsticker--treeview-list-items newsticker--treeview-current-feed))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1203 (newsticker--treeview-current-vfeed
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1204 (newsticker--treeview-list-items-with-age
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1205 (intern newsticker--treeview-current-vfeed))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1206 (newsticker--treeview-tree-update-highlight)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1207 (newsticker--treeview-list-update-highlight))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1208
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1209 (defun newsticker-treeview-quit ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1210 "Quit newsticker treeview."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1211 (interactive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1212 (newsticker-treeview-save)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1213 (setq newsticker--sentinel-callback nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1214 (setq newsticker--window-config (current-window-configuration))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1215 (bury-buffer "*Newsticker Tree*")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1216 (bury-buffer "*Newsticker List*")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1217 (bury-buffer "*Newsticker Item*")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1218 (set-window-configuration newsticker--saved-window-config)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1219 (when newsticker--frame
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1220 (if (frame-live-p newsticker--frame)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1221 (delete-frame newsticker--frame))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1222 (setq newsticker--frame nil)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1223
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1224 (defun newsticker-treeview-save ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1225 "Save newsticker data including treeview settings."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1226 (interactive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1227 (newsticker--cache-save)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1228 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1229 (let ((coding-system-for-write 'utf-8)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1230 (buf (find-file-noselect newsticker-groups-filename)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1231 (when buf
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1232 (set-buffer buf)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1233 (setq buffer-undo-list t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1234 (erase-buffer)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1235 (insert ";; -*- coding: utf-8 -*-\n")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1236 (insert (prin1-to-string newsticker-groups))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1237 (save-buffer)))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1238
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1239 (defun newsticker--treeview-load ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1240 "Load treeview settings."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1241 (let* ((coding-system-for-read 'utf-8)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1242 (buf (and (file-exists-p newsticker-groups-filename)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1243 (find-file-noselect newsticker-groups-filename))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1244 (when buf
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1245 (set-buffer buf)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1246 (goto-char (point-min))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1247 (condition-case nil
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1248 (setq newsticker-groups (read buf))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1249 (error
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1250 (message "Error while reading newsticker groups file!")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1251 (setq newsticker-groups nil))))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1252
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1253
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1254 (defun newsticker-treeview-scroll-item ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1255 "Scroll current item."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1256 (interactive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1257 (save-selected-window
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1258 (select-window (newsticker--treeview-item-window) t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1259 (scroll-up 1)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1260
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1261 (defun newsticker-treeview-show-item ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1262 "Show current item."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1263 (interactive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1264 (newsticker--treeview-list-update-highlight)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1265 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1266 (set-buffer (newsticker--treeview-list-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1267 (beginning-of-line)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1268 (let ((item (get-text-property (point) :nt-item))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1269 (feed (get-text-property (point) :nt-feed)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1270 (newsticker--treeview-item-show item feed)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1271 (newsticker--treeview-tree-update-tag
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1272 (newsticker--treeview-get-current-node) t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1273 (newsticker--treeview-tree-update-highlight))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1274
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1275 (defun newsticker-treeview-next-item ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1276 "Move to next item."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1277 (interactive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1278 (newsticker--treeview-restore-buffers)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1279 (save-current-buffer
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1280 (set-buffer (newsticker--treeview-list-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1281 (if (newsticker--treeview-list-highlight-start)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1282 (forward-line 1))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1283 (if (eobp)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1284 (forward-line -1)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1285 (newsticker-treeview-show-item))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1286
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1287 (defun newsticker-treeview-prev-item ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1288 "Move to previous item."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1289 (interactive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1290 (newsticker--treeview-restore-buffers)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1291 (save-current-buffer
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1292 (set-buffer (newsticker--treeview-list-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1293 (forward-line -1))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1294 (newsticker-treeview-show-item))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1295
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1296 (defun newsticker-treeview-next-new-or-immortal-item ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1297 "Move to next new or immortal item."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1298 (interactive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1299 (newsticker--treeview-restore-buffers)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1300 (newsticker--treeview-list-clear-highlight)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1301 (catch 'found
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1302 (let ((index (newsticker-treeview-next-item)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1303 (while t
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1304 (save-current-buffer
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1305 (set-buffer (newsticker--treeview-list-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1306 (forward-line 1)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1307 (when (eobp)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1308 (forward-line -1)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1309 (throw 'found nil)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1310 (when (memq (newsticker--age
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1311 (newsticker--treeview-get-selected-item)) '(new immortal))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1312 (newsticker-treeview-show-item)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1313 (throw 'found t))))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1314
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1315 (defun newsticker-treeview-prev-new-or-immortal-item ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1316 "Move to previous new or immortal item."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1317 (interactive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1318 (newsticker--treeview-restore-buffers)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1319 (newsticker--treeview-list-clear-highlight)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1320 (catch 'found
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1321 (let ((index (newsticker-treeview-next-item)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1322 (while t
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1323 (save-current-buffer
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1324 (set-buffer (newsticker--treeview-list-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1325 (forward-line -1)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1326 (when (bobp)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1327 (throw 'found nil)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1328 (when (memq (newsticker--age
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1329 (newsticker--treeview-get-selected-item)) '(new immortal))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1330 (newsticker-treeview-show-item)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1331 (throw 'found t))))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1332
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1333 (defun newsticker--treeview-get-selected-item ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1334 "Return item that is currently selected in list buffer."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1335 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1336 (set-buffer (newsticker--treeview-list-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1337 (beginning-of-line)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1338 (get-text-property (point) :nt-item)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1339
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1340 (defun newsticker-treeview-mark-item-old (&optional dont-proceed)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1341 "Mark current item as old unless it is obsolete.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1342 Move to next item unless DONT-PROCEED is non-nil."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1343 (interactive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1344 (let ((item (newsticker--treeview-get-selected-item)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1345 (unless (eq (newsticker--age item) 'obsolete)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1346 (newsticker--treeview-mark-item item 'old)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1347 (unless dont-proceed
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1348 (newsticker-treeview-next-item)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1349
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1350 (defun newsticker-treeview-toggle-item-immortal ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1351 "Toggle immortality of current item."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1352 (interactive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1353 (let* ((item (newsticker--treeview-get-selected-item))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1354 (new-age (if (eq (newsticker--age item) 'immortal)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1355 'old
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1356 'immortal)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1357 (newsticker--treeview-mark-item item new-age)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1358 (newsticker-treeview-next-item)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1359
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1360 (defun newsticker--treeview-mark-item (item new-age)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1361 "Mark ITEM with NEW-AGE."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1362 (when item
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1363 (setcar (nthcdr 4 item) new-age)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1364 ;; clean up ticker FIXME
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1365 ))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1366
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1367 (defun newsticker-treeview-mark-list-items-old ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1368 "Mark all listed items as old."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1369 (interactive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1370 (let ((current-feed (or newsticker--treeview-current-feed
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1371 newsticker--treeview-current-vfeed)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1372 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1373 (set-buffer (newsticker--treeview-list-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1374 (goto-char (point-min))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1375 (while (not (eobp))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1376 (let ((item (get-text-property (point) :nt-item)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1377 (unless (memq (newsticker--age item) '(immortal obsolete))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1378 (newsticker--treeview-mark-item item 'old)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1379 (forward-line 1)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1380 (newsticker--treeview-tree-update-tags)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1381 (if current-feed
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1382 (newsticker-treeview-jump current-feed))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1383
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1384 (defun newsticker-treeview-save-item ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1385 "Save current item."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1386 (interactive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1387 (newsticker-save-item (or newsticker--treeview-current-feed
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1388 newsticker--treeview-current-vfeed)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1389 (newsticker--treeview-get-selected-item)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1390
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1391 (defun newsticker--treeview-set-current-node (node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1392 "Make NODE the current node."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1393 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1394 (set-buffer (newsticker--treeview-tree-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1395 (setq newsticker--treeview-current-node-id
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1396 (widget-get node :nt-id))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1397 (setq newsticker--treeview-current-feed (widget-get node :nt-feed))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1398 (setq newsticker--treeview-current-vfeed (widget-get node :nt-vfeed))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1399 ;;(message "newsticker--treeview-set-current-node %s/%s" (widget-get node :tag)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1400 ;; (widget-get node :nt-id))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1401 ;; node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1402 (newsticker--treeview-tree-update-highlight)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1403
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1404 (defun newsticker--treeview-get-first-child (node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1405 "Get first child of NODE."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1406 (let ((children (widget-get node :children)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1407 (if children
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1408 (car children)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1409 nil)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1410
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1411 (defun newsticker--treeview-get-second-child (node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1412 "Get scond child of NODE."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1413 (let ((children (widget-get node :children)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1414 (if children
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1415 (car (cdr children))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1416 nil)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1417
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1418 (defun newsticker--treeview-get-last-child (node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1419 "Get last child of NODE."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1420 ;;(message "newsticker--treeview-get-last-child %s" (widget-get node :tag))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1421 (let ((children (widget-get node :children)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1422 (if children
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1423 (car (reverse children))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1424 nil)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1425
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1426 (defun newsticker--treeview-get-feed-vfeed (node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1427 "Get (virtual) feed of NODE."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1428 (or (widget-get node :nt-feed) (widget-get node :nt-vfeed)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1429
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1430 (defun newsticker--treeview-get-next-sibling (node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1431 "Get next sibling of NODE."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1432 (let ((parent (widget-get node :parent)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1433 (catch 'found
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1434 (let ((children (widget-get parent :children)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1435 (while children
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1436 (if (newsticker--treeview-nodes-eq (car children) node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1437 (throw 'found (car (cdr children))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1438 (setq children (cdr children)))))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1439
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1440 (defun newsticker--treeview-get-prev-sibling (node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1441 "Get previous sibling of NODE."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1442 (let ((parent (widget-get node :parent)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1443 (catch 'found
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1444 (let ((children (widget-get parent :children))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1445 (prev nil))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1446 (while children
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1447 (if (and (newsticker--treeview-nodes-eq (car children) node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1448 (widget-get prev :nt-id))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1449 (throw 'found prev))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1450 (setq prev (car children))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1451 (setq children (cdr children)))))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1452
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1453 (defun newsticker--treeview-get-next-uncle (node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1454 "Get next uncle of NODE, i.e. parent's next sibling."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1455 (let* ((parent (widget-get node :parent))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1456 (grand-parent (widget-get parent :parent)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1457 (catch 'found
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1458 (let ((uncles (widget-get grand-parent :children)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1459 (while uncles
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1460 (if (newsticker--treeview-nodes-eq (car uncles) parent)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1461 (throw 'found (car (cdr uncles))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1462 (setq uncles (cdr uncles)))))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1463
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1464 (defun newsticker--treeview-get-prev-uncle (node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1465 "Get previous uncle of NODE, i.e. parent's previous sibling."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1466 (let* ((parent (widget-get node :parent))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1467 (grand-parent (widget-get parent :parent)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1468 (catch 'found
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1469 (let ((uncles (widget-get grand-parent :children))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1470 (prev nil))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1471 (while uncles
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1472 (if (newsticker--treeview-nodes-eq (car uncles) parent)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1473 (throw 'found prev))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1474 (setq prev (car uncles))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1475 (setq uncles (cdr uncles)))))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1476
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1477 (defun newsticker--treeview-get-other-tree ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1478 "Get other tree."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1479 (if (and (newsticker--treeview-get-current-node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1480 (widget-get (newsticker--treeview-get-current-node) :nt-feed))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1481 newsticker--treeview-vfeed-tree
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1482 newsticker--treeview-feed-tree))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1483
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1484 (defun newsticker--treeview-activate-node (node &optional backward)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1485 "Activate NODE.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1486 If NODE is a tree widget the node's first subnode is activated.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1487 If BACKWARD is non-nil the last subnode of the previous sibling
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1488 is activated."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1489 (newsticker--treeview-set-current-node node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1490 (save-current-buffer
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1491 (set-buffer (newsticker--treeview-tree-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1492 (cond ((eq (widget-type node) 'tree-widget)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1493 (unless (widget-get node :open)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1494 (widget-put node :open nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1495 (widget-apply-action node))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1496 (newsticker--treeview-activate-node
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1497 (if backward
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1498 (newsticker--treeview-get-last-child node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1499 (newsticker--treeview-get-second-child node))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1500 (node
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1501 (widget-apply-action node)))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1502
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1503 (defun newsticker-treeview-next-feed ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1504 "Move to next feed."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1505 (interactive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1506 (newsticker--treeview-restore-buffers)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1507 (let ((cur (newsticker--treeview-get-current-node)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1508 ;;(message "newsticker-treeview-next-feed from %s"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1509 ;; (widget-get cur :tag))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1510 (if cur
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1511 (let ((new (or (newsticker--treeview-get-next-sibling cur)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1512 (newsticker--treeview-get-next-uncle cur)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1513 (newsticker--treeview-get-other-tree))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1514 (newsticker--treeview-activate-node new))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1515 (newsticker--treeview-activate-node
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1516 (car (widget-get newsticker--treeview-feed-tree :children)))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1517 (newsticker--treeview-tree-update-highlight))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1518
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1519 (defun newsticker-treeview-prev-feed ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1520 "Move to previous feed."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1521 (interactive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1522 (newsticker--treeview-restore-buffers)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1523 (let ((cur (newsticker--treeview-get-current-node)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1524 (message "newsticker-treeview-prev-feed from %s"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1525 (widget-get cur :tag))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1526 (if cur
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1527 (let ((new (or (newsticker--treeview-get-prev-sibling cur)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1528 (newsticker--treeview-get-prev-uncle cur)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1529 (newsticker--treeview-get-other-tree))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1530 (newsticker--treeview-activate-node new t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1531 (newsticker--treeview-activate-node
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1532 (car (widget-get newsticker--treeview-feed-tree :children)) t)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1533 (newsticker--treeview-tree-update-highlight))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1534
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1535 (defun newsticker-treeview-next-page ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1536 "Scroll item buffer."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1537 (interactive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1538 (save-selected-window
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1539 (select-window (newsticker--treeview-item-window) t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1540 (condition-case nil
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1541 (scroll-up nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1542 (error
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1543 (goto-char (point-min))))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1544
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1545
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1546 (defun newsticker--treeview-unfold-node (feed-name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1547 "Recursively show subtree above the node that represents FEED-NAME."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1548 (let ((node (newsticker--treeview-get-node-of-feed feed-name)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1549 (unless node
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1550 (let* ((group-name (or (car (newsticker--group-find-group-for-feed
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1551 feed-name))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1552 (newsticker--group-get-parent-group
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1553 feed-name))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1554 (newsticker--treeview-unfold-node group-name))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1555 (setq node (newsticker--treeview-get-node-of-feed feed-name)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1556 (when node
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1557 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1558 (set-buffer (newsticker--treeview-tree-buffer))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1559 (widget-put node :nt-selected t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1560 (widget-apply-action node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1561 (newsticker--treeview-set-current-node node)))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1562
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1563 (defun newsticker-treeview-jump (feed-name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1564 "Jump to feed FEED-NAME in newsticker treeview."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1565 (interactive
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1566 (list (let ((completion-ignore-case t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1567 (if newsticker-treeview-own-frame
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1568 (set-window-dedicated-p (newsticker--treeview-item-window) nil))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1569 (completing-read
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1570 "Jump to feed: "
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1571 (mapcar 'car (append newsticker-url-list
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1572 newsticker-url-list-defaults))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1573 nil t))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1574 (if newsticker-treeview-own-frame
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1575 (set-window-dedicated-p (newsticker--treeview-item-window) t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1576 (newsticker--treeview-unfold-node feed-name))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1577
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1578 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1579 ;;; Groups
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1580 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1581 (defun newsticker--group-do-find-group-for-feed (feed-name node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1582 "Recursively find FEED-NAME in NODE."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1583 (if (member feed-name (cdr node))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1584 (throw 'found node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1585 (mapc (lambda (n)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1586 (if (listp n)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1587 (newsticker--group-do-find-group-for-feed feed-name n)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1588 (cdr node))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1589
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1590 (defun newsticker--group-find-group-for-feed (feed-name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1591 "Find group containing FEED-NAME."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1592 (catch 'found
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1593 (newsticker--group-do-find-group-for-feed feed-name
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1594 newsticker-groups)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1595 nil))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1596
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1597 (defun newsticker--group-do-get-group (name node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1598 "Recursively find group with NAME below NODE."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1599 (if (string= name (car node))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1600 (throw 'found node)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1601 (mapc (lambda (n)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1602 (if (listp n)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1603 (newsticker--group-do-get-group name n)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1604 (cdr node))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1605
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1606 (defun newsticker--group-get-group (name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1607 "Find group with NAME."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1608 (catch 'found
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1609 (mapc (lambda (n)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1610 (if (listp n)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1611 (newsticker--group-do-get-group name n)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1612 newsticker-groups)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1613 nil))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1614
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1615 (defun newsticker--group-do-get-parent-group (name node parent)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1616 "Recursively find parent group for NAME from NODE which is a child of PARENT."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1617 (if (string= name (car node))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1618 (throw 'found parent)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1619 (mapc (lambda (n)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1620 (if (listp n)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1621 (newsticker--group-do-get-parent-group name n (car node))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1622 (cdr node))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1623
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1624 (defun newsticker--group-get-parent-group (name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1625 "Find parent group for group named NAME."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1626 (catch 'found
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1627 (mapc (lambda (n)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1628 (if (listp n)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1629 (newsticker--group-do-get-parent-group
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1630 name n (car newsticker-groups))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1631 newsticker-groups)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1632 nil))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1633
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1634
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1635 (defun newsticker--group-get-subgroups (group &optional recursive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1636 "Return list of subgroups for GROUP.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1637 If RECURSIVE is non-nil recursively get subgroups and return a nested list."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1638 (let ((result nil))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1639 (mapc (lambda (n)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1640 (when (listp n)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1641 (setq result (cons (car n) result))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1642 (let ((subgroups (newsticker--group-get-subgroups n recursive)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1643 (when subgroups
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1644 (setq result (append subgroups result))))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1645 group)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1646 result))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1647
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1648 (defun newsticker--group-all-groups ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1649 "Return nested list of all groups."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1650 (newsticker--group-get-subgroups newsticker-groups t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1651
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1652 (defun newsticker--group-get-feeds (group &optional recursive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1653 "Return list of all feeds in GROUP.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1654 If RECURSIVE is non-nil recursively get feeds of subgroups and
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1655 return a nested list."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1656 (let ((result nil))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1657 (mapc (lambda (n)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1658 (if (not (listp n))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1659 (setq result (cons n result))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1660 (if recursive
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1661 (let ((subfeeds (newsticker--group-get-feeds n t)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1662 (when subfeeds
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1663 (setq result (append subfeeds result)))))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1664 group)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1665 result))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1666
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1667 (defun newsticker-group-add-group (name parent)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1668 "Add group NAME to group PARENT."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1669 (interactive
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1670 (list (read-string "Group Name: ")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1671 (let ((completion-ignore-case t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1672 (if newsticker-treeview-own-frame
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1673 (set-window-dedicated-p (newsticker--treeview-item-window) nil))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1674 (completing-read "Parent Group: " (newsticker--group-all-groups)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1675 nil t))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1676 (if newsticker-treeview-own-frame
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1677 (set-window-dedicated-p (newsticker--treeview-item-window) t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1678 (if (newsticker--group-get-group name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1679 (error "Group %s exists already" name))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1680 (let ((p (if (and parent (not (string= parent "")))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1681 (newsticker--group-get-group parent)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1682 newsticker-groups)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1683 (unless p
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1684 (error "Parent %s does not exist" parent))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1685 (setcdr p (cons (list name) (cdr p))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1686 (newsticker--treeview-tree-update))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1687
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1688 (defun newsticker-group-move-feed (name group-name &optional no-update)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1689 "Move feed NAME to group GROUP-NAME.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1690 Update teeview afterwards unless NO-UPDATE is non-nil."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1691 (interactive
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1692 (let ((completion-ignore-case t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1693 (if newsticker-treeview-own-frame
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1694 (set-window-dedicated-p (newsticker--treeview-item-window) nil))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1695 (list (completing-read "Feed Name: "
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1696 (mapcar 'car newsticker-url-list)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1697 nil t newsticker--treeview-current-feed)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1698 (completing-read "Group Name: " (newsticker--group-all-groups)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1699 nil t))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1700 (if newsticker-treeview-own-frame
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1701 (set-window-dedicated-p (newsticker--treeview-item-window) t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1702 (let ((group (if (and group-name (not (string= group-name "")))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1703 (newsticker--group-get-group group-name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1704 newsticker-groups)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1705 (unless group
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1706 (error "Group %s does not exist" group-name))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1707 (while (let ((old-group
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1708 (newsticker--group-find-group-for-feed name)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1709 (when old-group
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1710 (delete name old-group))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1711 old-group))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1712 (setcdr group (cons name (cdr group)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1713 (unless no-update
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1714 (newsticker--treeview-tree-update)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1715 (newsticker-treeview-update))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1716
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1717 (defun newsticker-group-delete-group (name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1718 "Remove group NAME."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1719 (interactive
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1720 (let ((completion-ignore-case t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1721 (if newsticker-treeview-own-frame
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1722 (set-window-dedicated-p (newsticker--treeview-item-window) nil))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1723 (list (completing-read "Group Name: " (newsticker--group-all-groups)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1724 nil t))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1725 (if newsticker-treeview-own-frame
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1726 (set-window-dedicated-p (newsticker--treeview-item-window) t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1727 (let* ((g (newsticker--group-get-group name))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1728 (p (or (newsticker--group-get-parent-group name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1729 newsticker-groups)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1730 (unless g
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1731 (error "Group %s does not exist" name))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1732 (delete g p))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1733 (newsticker--treeview-tree-update))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1734
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1735 (defun newsticker--count-groups (group)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1736 "Recursively count number of subgroups of GROUP."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1737 (let ((result 1))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1738 (mapc (lambda (g)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1739 (if (listp g)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1740 (setq result (+ result (newsticker--count-groups g)))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1741 (cdr group))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1742 result))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1743
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1744 (defun newsticker--count-grouped-feeds (group)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1745 "Recursively count number of feeds in GROUP and its subgroups."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1746 (let ((result 0))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1747 (mapc (lambda (g)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1748 (if (listp g)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1749 (setq result (+ result (newsticker--count-grouped-feeds g)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1750 (setq result (1+ result))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1751 (cdr group))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1752 result))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1753
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1754 (defun newsticker--group-remove-obsolete-feeds (group)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1755 "Recursively remove obselete feeds from GROUP."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1756 (let ((result nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1757 (urls (append newsticker-url-list newsticker-url-list-defaults)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1758 (mapc (lambda (g)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1759 (if (listp g)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1760 (let ((sub-groups
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1761 (newsticker--group-remove-obsolete-feeds g)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1762 (if sub-groups
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1763 (setq result (cons sub-groups result))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1764 (if (assoc g urls)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1765 (setq result (cons g result)))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1766 (cdr group))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1767 (if result
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1768 (cons (car group) (reverse result))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1769 result)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1770
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1771 (defun newsticker--group-manage-orphan-feeds ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1772 "Put unmanaged feeds into `newsticker-groups'.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1773 Remove obsolete feeds as well."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1774 (let ((new-feed nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1775 (grouped-feeds (newsticker--count-grouped-feeds newsticker-groups)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1776 (mapc (lambda (f)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1777 (unless (newsticker--group-find-group-for-feed (car f))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1778 (setq new-feed t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1779 (newsticker-group-move-feed (car f) nil t)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1780 (append newsticker-url-list-defaults newsticker-url-list))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1781 (setq newsticker-groups
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1782 (newsticker--group-remove-obsolete-feeds newsticker-groups))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1783 (if (or new-feed
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1784 (not (= grouped-feeds
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1785 (newsticker--count-grouped-feeds newsticker-groups))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1786 (newsticker--treeview-tree-update))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1787
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1788 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1789 ;;; Modes
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1790 ;; ======================================================================
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1791 (defun newsticker--treeview-create-groups-menu (group-list
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1792 excluded-group)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1793 "Create menu for GROUP-LIST omitting EXCLUDED-GROUP."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1794 (let ((menu (make-sparse-keymap (if (stringp (car group-list))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1795 (car group-list)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1796 "Move to group..."))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1797 (mapc (lambda (g)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1798 (when (listp g)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1799 (let ((title (if (stringp (car g))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1800 (car g)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1801 "Move to group...")))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1802 (unless (eq g excluded-group)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1803 (define-key menu (vector (intern title))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1804 (list 'menu-item title
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1805 (newsticker--treeview-create-groups-menu
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1806 (cdr g) excluded-group)))))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1807 (reverse group-list))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1808 menu))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1809
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1810 (defun newsticker--treeview-create-tree-menu (feed-name)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1811 "Create tree menu for FEED-NAME."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1812 (let ((menu (make-sparse-keymap feed-name)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1813 (define-key menu [newsticker-treeview-mark-list-items-old]
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1814 (list 'menu-item "Mark all items old"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1815 'newsticker-treeview-mark-list-items-old))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1816 (define-key menu [move]
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1817 (list 'menu-item "Move to group..."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1818 (newsticker--treeview-create-groups-menu
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1819 newsticker-groups
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1820 (newsticker--group-get-group feed-name))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1821 menu))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1822
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1823 ;;(makunbound 'newsticker-treeview-list-menu) ;FIXME
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1824 (defvar newsticker-treeview-list-menu
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1825 (let ((menu (make-sparse-keymap "Newsticker List")))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1826 (define-key menu [newsticker-treeview-mark-list-items-old]
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1827 (list 'menu-item "Mark all items old"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1828 'newsticker-treeview-mark-list-items-old))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1829 menu)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1830 "Map for newsticker tree menu.")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1831
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1832 ;;(makunbound 'newsticker-treeview-mode-map) ;FIXME
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1833 (defvar newsticker-treeview-mode-map
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1834 (let ((map (make-sparse-keymap 'newsticker-treeview-mode-map)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1835 (define-key map " " 'newsticker-treeview-next-page)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1836 (define-key map "a" 'newsticker-add-url)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1837 (define-key map "F" 'newsticker-treeview-prev-feed)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1838 (define-key map "f" 'newsticker-treeview-next-feed)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1839 (define-key map "g" 'newsticker-treeview-get-news)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1840 (define-key map "G" 'newsticker-get-all-news)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1841 (define-key map "i" 'newsticker-treeview-toggle-item-immortal)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1842 (define-key map "j" 'newsticker-treeview-jump)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1843 (define-key map "n" 'newsticker-treeview-next-item)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1844 (define-key map "N" 'newsticker-treeview-next-new-or-immortal-item)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1845 (define-key map "O" 'newsticker-treeview-mark-list-items-old)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1846 (define-key map "o" 'newsticker-treeview-mark-item-old)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1847 (define-key map "p" 'newsticker-treeview-prev-item)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1848 (define-key map "P" 'newsticker-treeview-prev-new-or-immortal-item)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1849 (define-key map "q" 'newsticker-treeview-quit)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1850 (define-key map "S" 'newsticker-treeview-save-item)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1851 (define-key map "s" 'newsticker-treeview-save)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1852 (define-key map "u" 'newsticker-treeview-update)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1853 (define-key map "v" 'newsticker-treeview-browse-url)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1854 ;;(define-key map "\n" 'newsticker-treeview-scroll-item)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1855 ;;(define-key map "\C-m" 'newsticker-treeview-scroll-item)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1856 (define-key map "\M-m" 'newsticker-group-move-feed)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1857 (define-key map "\M-a" 'newsticker-group-add-group)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1858 map)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1859 "Mode map for newsticker treeview.")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1860
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1861 (defun newsticker-treeview-mode ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1862 "Major mode for Newsticker Treeview.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1863 \\{newsticker-treeview-mode-map}"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1864 (kill-all-local-variables)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1865 (use-local-map newsticker-treeview-mode-map)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1866 (setq major-mode 'newsticker-treeview-mode)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1867 (setq mode-name "Newsticker TV")
95753
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1868 (if (boundp 'tool-bar-map)
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1869 (set (make-local-variable 'tool-bar-map)
37e144abcf02 (w3m-toggle-inline-images): Declare.
Glenn Morris <rgm@gnu.org>
parents: 95685
diff changeset
1870 newsticker-treeview-tool-bar-map))
95679
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1871 (setq buffer-read-only t
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1872 truncate-lines t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1873
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1874 ;;(makunbound 'newsticker-treeview-list-mode-map);FIXME
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1875 (define-derived-mode newsticker-treeview-list-mode newsticker-treeview-mode
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1876 "Item List"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1877 (let ((header (concat
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1878 (propertize " " 'display '(space :align-to 0))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1879 (newsticker-treeview-list-make-sort-button "*" 'sort-by-age)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1880 (propertize " " 'display '(space :align-to 2))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1881 (if newsticker--treeview-list-show-feed
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1882 (concat "Feed"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1883 (propertize " " 'display '(space :align-to 12)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1884 "")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1885 (newsticker-treeview-list-make-sort-button "Date"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1886 'sort-by-time)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1887 (if newsticker--treeview-list-show-feed
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1888 (propertize " " 'display '(space :align-to 28))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1889 (propertize " " 'display '(space :align-to 18)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1890 (newsticker-treeview-list-make-sort-button "Title"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1891 'sort-by-title))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1892 (setq header-line-format header))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1893 (define-key newsticker-treeview-list-mode-map [down-mouse-3]
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1894 newsticker-treeview-list-menu))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1895
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1896 (defun newsticker-treeview-tree-click (event)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1897 "Handle click EVENT on a tag in the newsticker tree."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1898 (interactive "e")
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1899 (save-excursion
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1900 (switch-to-buffer (window-buffer (posn-window (event-end event))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1901 (newsticker-treeview-tree-do-click (posn-point (event-end event)))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1902
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1903 (defun newsticker-treeview-tree-do-click (&optional pos event)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1904 "Actually handle click event.
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1905 POS gives the position where EVENT occurred."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1906 (interactive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1907 (unless pos (setq pos (point)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1908 (let ((pos (or pos (point)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1909 (nt-id (get-text-property pos :nt-id))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1910 (item (get-text-property pos :nt-item)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1911 (cond (item
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1912 ;; click in list buffer
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1913 (newsticker-treeview-show-item))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1914 (t
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1915 ;; click in tree buffer
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1916 (let ((w (newsticker--treeview-get-node nt-id)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1917 (when w
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1918 (newsticker--treeview-tree-update-tag w t t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1919 (setq w (newsticker--treeview-get-node nt-id))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1920 (widget-put w :nt-selected t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1921 (widget-apply w :action event)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1922 (newsticker--treeview-set-current-node w))))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1923 (newsticker--treeview-tree-update-highlight))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1924
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1925 (defun newsticker--treeview-restore-buffers ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1926 "Restore treeview buffers."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1927 (catch 'error
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1928 (dotimes (i 3)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1929 (let ((win (nth i newsticker--treeview-windows))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1930 (buf (nth i newsticker--treeview-buffers)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1931 (unless (window-live-p win)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1932 (newsticker--treeview-window-init)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1933 (newsticker--treeview-buffer-init)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1934 (throw 'error t))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1935 (unless (eq (window-buffer win) buf)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1936 (set-window-buffer win buf t))))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1937
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1938 (defun newsticker--treeview-frame-init ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1939 "Initialize treeview frame."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1940 (when newsticker-treeview-own-frame
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1941 (unless (and newsticker--frame (frame-live-p newsticker--frame))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1942 (setq newsticker--frame (make-frame '((name . "Newsticker")))))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1943 (select-frame-set-input-focus newsticker--frame)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1944 (raise-frame newsticker--frame)))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1945
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1946 (defun newsticker--treeview-window-init ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1947 "Initialize treeview windows."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1948 (setq newsticker--saved-window-config (current-window-configuration))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1949 (setq newsticker--treeview-windows nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1950 (setq newsticker--treeview-buffers nil)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1951 (delete-other-windows)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1952 (split-window-horizontally 25)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1953 (add-to-list 'newsticker--treeview-windows (selected-window) t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1954 (other-window 1)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1955 (split-window-vertically 10)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1956 (add-to-list 'newsticker--treeview-windows (selected-window) t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1957 (other-window 1)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1958 (add-to-list 'newsticker--treeview-windows (selected-window) t)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1959 (other-window 1))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1960
95685
ed883167b994 Autoload cookies for newsticker.
Ulf Jasper <ulf.jasper@web.de>
parents: 95684
diff changeset
1961 ;;;###autoload
95679
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1962 (defun newsticker-treeview ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1963 "Start newsticker treeview."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1964 (interactive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1965 (newsticker--treeview-load)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1966 (setq newsticker--sentinel-callback 'newsticker-treeview-update)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1967 (newsticker--treeview-frame-init)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1968 (newsticker--treeview-window-init)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1969 (newsticker--treeview-buffer-init)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1970 (newsticker--group-manage-orphan-feeds)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1971 (if newsticker--window-config
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1972 (set-window-configuration newsticker--window-config))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1973 (newsticker--treeview-set-current-node newsticker--treeview-feed-tree)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1974 (newsticker-start t) ;; will start only if not running
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1975 (newsticker-treeview-update)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1976 (newsticker--treeview-item-show-text
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1977 "Newsticker"
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1978 "Welcome to newsticker!"))
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1979
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1980 (defun newsticker-treeview-get-news ()
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1981 "Get news for current feed."
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1982 (interactive)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1983 (when newsticker--treeview-current-feed
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1984 (newsticker-get-news newsticker--treeview-current-feed)))
95760
e62f5d3e9fad Remove trailing whitespace.
Glenn Morris <rgm@gnu.org>
parents: 95753
diff changeset
1985
95679
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1986 (provide 'newsticker-treeview)
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1987
95684
4ab45b5c92cd Add arch tagline
Miles Bader <miles@gnu.org>
parents: 95679
diff changeset
1988 ;; arch-tag: 5dbaff48-1f3e-4fc6-8ebd-e966fc90d2d4
95679
affa94f302e7 Initial check-in.
Ulf Jasper <ulf.jasper@web.de>
parents:
diff changeset
1989 ;;; newsticker-treeview.el ends here