changeset 106408:53d1b718f76a

Newsticker fixes/changes.
author Ulf Jasper <ulf.jasper@web.de>
date Fri, 04 Dec 2009 19:27:42 +0000
parents 1119f2c554bc
children 87bc434475d4
files lisp/ChangeLog lisp/net/newst-backend.el lisp/net/newst-treeview.el
diffstat 3 files changed, 98 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Dec 04 16:34:22 2009 +0000
+++ b/lisp/ChangeLog	Fri Dec 04 19:27:42 2009 +0000
@@ -1,3 +1,23 @@
+2009-12-04  Ulf Jasper  <ulf.jasper@web.de>
+
+	* net/newst-treeview.el
+	(newsticker--treeview-list-highlight-start): Restored call to
+	save-excursion: Selected item was stuck.
+	(newsticker--treeview-list-select): New.
+	(newsticker--treeview-item-show-text)
+	(newsticker--treeview-item-show)
+	(newsticker--treeview-item-update): Use new
+	newsticker-treeview-item-mode.
+	(newsticker-treeview-update): Keep current item.
+	(newsticker-treeview-next-new-or-immortal-item): Doc change.
+	(newsticker--treeview-first-feed): Doc change.
+	(newsticker-treeview-list-menu)
+	(newsticker-treeview-item-menu): Added menu entries.
+	(newsticker-treeview-item-mode): New.
+
+	* net/newst-backend.el (newsticker-customize): delete other
+	windows.
+
 2009-12-04  Sam Steingold  <sds@gnu.org>
 
 	* log-view.el (log-view-mode-map): "q" calls quit-window,
--- a/lisp/net/newst-backend.el	Fri Dec 04 16:34:22 2009 +0000
+++ b/lisp/net/newst-backend.el	Fri Dec 04 19:27:42 2009 +0000
@@ -7,7 +7,7 @@
 ;; Filename:    newst-backend.el
 ;; URL:         http://www.nongnu.org/newsticker
 ;; Keywords:    News, RSS, Atom
-;; Time-stamp:  "23. Januar 2009, 19:39:22 (ulf)"
+;; Time-stamp:  "4. Dezember 2009, 20:08:17 (ulf)"
 
 ;; ======================================================================
 
@@ -717,6 +717,7 @@
 (defun newsticker-customize ()
   "Open the newsticker customization group."
   (interactive)
+  (delete-other-windows)
   (customize-group "newsticker"))
 
 ;; ======================================================================
--- a/lisp/net/newst-treeview.el	Fri Dec 04 16:34:22 2009 +0000
+++ b/lisp/net/newst-treeview.el	Fri Dec 04 19:27:42 2009 +0000
@@ -7,7 +7,7 @@
 ;; URL:         http://www.nongnu.org/newsticker
 ;; Created:     2007
 ;; Keywords:    News, RSS, Atom
-;; Time-stamp:  "15. April 2009, 19:51:17 (ulf)"
+;; Time-stamp:  "4. Dezember 2009, 20:07:40 (ulf)"
 
 ;; ======================================================================
 
@@ -597,8 +597,9 @@
 (defun newsticker--treeview-list-highlight-start ()
   "Return position of selection in treeview list buffer."
   (with-current-buffer (newsticker--treeview-list-buffer)
-    (goto-char (point-min))
-    (next-single-property-change (point) :nt-selected)))
+    (save-excursion
+      (goto-char (point-min))
+      (next-single-property-change (point) :nt-selected))))
 
 (defun newsticker--treeview-list-update (clear-buffer)
   "Update the faces and highlight in the treeview list buffer.
@@ -665,6 +666,27 @@
                 'face face
                 'keymap newsticker-treeview-list-sort-button-map)))
 
+(defun newsticker--treeview-list-select (item)
+  "Select ITEM in treeview's list buffer."
+  (newsticker--treeview-list-clear-highlight)
+    (let (pos num-lines)
+      (save-current-buffer
+        (set-buffer (newsticker--treeview-list-buffer))
+        (goto-char (point-min))
+        (catch 'found
+          (while t
+            (let ((it (get-text-property (point) :nt-item)))
+              (when (eq it item)
+                (newsticker--treeview-list-update-highlight)
+                (newsticker--treeview-list-update-faces)
+                (newsticker--treeview-item-show
+                 item (get-text-property (point) :nt-feed))
+                (throw 'found t)))
+            (forward-line 1)
+            (when (eobp)
+              (goto-char (point-min))
+              (throw 'found nil)))))))
+
 ;; ======================================================================
 ;;; item window
 ;; ======================================================================
@@ -682,7 +704,7 @@
       (insert "\n\n" description)
       (when newsticker-justification
         (fill-region (point-min) (point-max) newsticker-justification))
-      (newsticker-treeview-mode)
+      (newsticker-treeview-item-mode)
       (goto-char (point-min)))))
 
 (defun newsticker--treeview-item-show (item feed-name-symbol)
@@ -716,7 +738,7 @@
                    (not is-rendered-HTML))
           (fill-region marker1 marker2 newsticker-justification))
 
-        (newsticker-treeview-mode)
+        (newsticker-treeview-item-mode)
         (goto-char (point-min))
         ;; insert logo at top
         (let* ((newsticker-enable-logo-manipulations nil)
@@ -787,7 +809,7 @@
     (set-buffer (newsticker--treeview-item-buffer))
     (let ((inhibit-read-only t))
       (erase-buffer))
-    (newsticker-treeview-mode)))
+    (newsticker-treeview-item-mode)))
 
 ;; ======================================================================
 ;;; Tree window
@@ -1193,17 +1215,22 @@
   "Update all treeview buffers and windows.
 Note: does not update the layout."
   (interactive)
-  (newsticker--group-manage-orphan-feeds)
-  (newsticker--treeview-list-update t)
-  (newsticker--treeview-item-update)
-  (newsticker--treeview-tree-update-tags)
-  (cond (newsticker--treeview-current-feed
-         (newsticker--treeview-list-items newsticker--treeview-current-feed))
-        (newsticker--treeview-current-vfeed
-         (newsticker--treeview-list-items-with-age
-          (intern newsticker--treeview-current-vfeed))))
-  (newsticker--treeview-tree-update-highlight)
-  (newsticker--treeview-list-update-highlight))
+  (let ((cur-item (newsticker--treeview-get-selected-item)))
+    (newsticker--group-manage-orphan-feeds)
+    (newsticker--treeview-list-update t)
+    (newsticker--treeview-item-update)
+    (newsticker--treeview-tree-update-tags)
+    (cond (newsticker--treeview-current-feed
+           (newsticker--treeview-list-items newsticker--treeview-current-feed))
+          (newsticker--treeview-current-vfeed
+           (newsticker--treeview-list-items-with-age
+            (intern newsticker--treeview-current-vfeed))))
+    (newsticker--treeview-tree-update-highlight)
+    (newsticker--treeview-list-update-highlight)
+    (let ((cur-feed (or newsticker--treeview-current-feed
+                        newsticker--treeview-current-vfeed)))
+      (if (and cur-feed cur-item)
+          (newsticker--treeview-list-select cur-item)))))
 
 (defun newsticker-treeview-quit ()
   "Quit newsticker treeview."
@@ -1307,7 +1334,8 @@
   "Move to next new or immortal item.
 Will move to next feed until an item is found.  Will not move if
 optional argument CURRENT-ITEM-COUNTS is t and current item is
-new or immortal."
+new or immortal.  Will not move from virtual to ordinary feed
+tree or vice versa if optional argument DONT-WRAP-TREES is non-nil."
   (interactive)
   (newsticker--treeview-restore-layout)
   (newsticker--treeview-list-clear-highlight)
@@ -1531,7 +1559,7 @@
            (widget-apply-action node)))))
 
 (defun newsticker--treeview-first-feed ()
-  "Jump to the depth-first feed in the newsticker-groups tree."
+  "Jump to the depth-first feed in the `newsticker-groups' tree."
   (newsticker-treeview-jump
    (car (reverse (newsticker--group-get-feeds newsticker-groups t)))))
 
@@ -1863,8 +1891,31 @@
     (define-key menu [newsticker-treeview-mark-list-items-old]
       (list 'menu-item "Mark all items old"
             'newsticker-treeview-mark-list-items-old))
+    (define-key menu [newsticker-treeview-mark-item-old]
+      (list 'menu-item "Mark current item old"
+            'newsticker-treeview-mark-item-old))
+    (define-key menu [newsticker-treeview-toggle-item-immortal]
+      (list 'menu-item "Mark current item immortal (toggle)"
+            'newsticker-treeview-toggle-item-immortal))
+    (define-key menu [newsticker-treeview-get-news]
+      (list 'menu-item "Get news for current feed"
+            'newsticker-treeview-get-news))
     menu)
-  "Map for newsticker tree menu.")
+  "Map for newsticker list menu.")
+
+(defvar newsticker-treeview-item-menu
+  (let ((menu (make-sparse-keymap "Newsticker Item")))
+    (define-key menu [newsticker-treeview-mark-item-old]
+      (list 'menu-item "Mark current item old"
+            'newsticker-treeview-mark-item-old))
+    (define-key menu [newsticker-treeview-toggle-item-immortal]
+      (list 'menu-item "Mark current item immortal (toggle)"
+            'newsticker-treeview-toggle-item-immortal))
+    (define-key menu [newsticker-treeview-get-news]
+      (list 'menu-item "Get news for current feed"
+            'newsticker-treeview-get-news))
+    menu)
+  "Map for newsticker item menu.")
 
 (defvar newsticker-treeview-mode-map
   (let ((map (make-sparse-keymap 'newsticker-treeview-mode-map)))
@@ -1929,6 +1980,11 @@
   (define-key newsticker-treeview-list-mode-map [down-mouse-3]
     newsticker-treeview-list-menu))
 
+(define-derived-mode newsticker-treeview-item-mode newsticker-treeview-mode
+  "Item"
+  (define-key newsticker-treeview-item-mode-map [down-mouse-3]
+    newsticker-treeview-item-menu))
+
 (defun newsticker-treeview-tree-click (event)
   "Handle click EVENT on a tag in the newsticker tree."
   (interactive "e")