* timestamp hilighting
@ 1996-11-11 5:32 David Moore
0 siblings, 0 replies; only message in thread
From: David Moore @ 1996-11-11 5:32 UTC (permalink / raw)
A while back a few of us talked about timestamping for groups,
and I decided that I liked coloring the lines more than tagging them
with complicated dates. Included below is a patch which gives you the
field 'group-age' to use in your 'gnus-group-hilite', so you can color
based on the time since you last visited the group. The patch also
fixes 'gnus-group-set-timestamp' so it can be used in
'gnus-group-catchup-group-hook' and other hooks. Finally it includes a
routine which can scan all your newsgroups and reset the timestamp if
there are no unread and no ticked articles.
I use the following in my gnus-group-hilite to let me know when 3 days
have passed since I last read a group. It's useful if I want to make
sure to check groups before they expire on the nntp server:
((and (or (> unread 0) (> ticked 0))
(<= level gnus-level-subscribed)
(> group-age (* 60 60 24 3)))
. ,(custom-face-lookup "dark magenta" nil nil t nil nil))
Also in my .gnus to enable everything:
(add-hook 'gnus-select-group-hook 'gnus-group-set-timestamp)
(add-hook 'gnus-group-catchup-group-hook 'gnus-group-set-timestamp)
(gnus-demon-add-scan-timestamps)
*** gnus-group.el.orig Sun Nov 10 20:16:02 1996
--- gnus-group.el Sun Nov 10 21:10:44 1996
***************
*** 1274,1279 ****
--- 1274,1280 ----
(level (or (gnus-info-level info) 9))
(score (or (gnus-info-score info) 0))
(ticked (gnus-range-length (cdr (assq 'tick marked))))
+ (group-age (gnus-group-timestamp-delta group))
(inhibit-read-only t))
;; Eval the cars of the lists until we find a match.
(while (and list
***************
*** 3390,3403 ****
(defun gnus-group-set-timestamp ()
"Change the timestamp of the current group to the current time.
! This function can be used in hooks like `gnus-select-group-hook'."
(let ((time (current-time)))
(setcdr (cdr time) nil)
! (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time)))
(defsubst gnus-group-timestamp (group)
"Return the timestamp for GROUP."
(gnus-group-get-parameter group 'timestamp))
(defun gnus-group-timestamp-string (group)
"Return a string of the timestamp for GROUP."
--- 3391,3415 ----
(defun gnus-group-set-timestamp ()
"Change the timestamp of the current group to the current time.
! This function can be used in hooks like `gnus-select-group-hook'
! or `gnus-group-catchup-group-hook'."
(let ((time (current-time)))
(setcdr (cdr time) nil)
! (gnus-group-set-parameter (or gnus-newsgroup-name group)
! 'timestamp time)))
(defsubst gnus-group-timestamp (group)
"Return the timestamp for GROUP."
(gnus-group-get-parameter group 'timestamp))
+
+ (defun gnus-group-timestamp-delta (group)
+ "Return the offset in seconds from the timestamp for GROUP to the current
+ time, as a floating point number."
+ (let* ((time (or (gnus-group-timestamp group)
+ (list 0 0)))
+ (delta (gnus-time-minus (current-time) time)))
+ (+ (* (nth 0 delta) 65536.0)
+ (nth 1 delta))))
(defun gnus-group-timestamp-string (group)
"Return a string of the timestamp for GROUP."
*** gnus.el.orig Sun Nov 10 21:14:40 1996
--- gnus.el Sun Nov 10 21:16:29 1996
***************
*** 1057,1062 ****
--- 1057,1063 ----
gnus-Folder-save-name gnus-folder-save-name)
("gnus-mh" :interactive t gnus-summary-save-in-folder)
("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
+ gnus-demon-add-rescan gnus-demon-add-scan-timestamps
gnus-demon-add-disconnection gnus-demon-add-handler
gnus-demon-remove-handler)
("gnus-demon" :interactive t
*** gnus-demon.el.orig Sun Nov 10 21:10:56 1996
--- gnus-demon.el Sun Nov 10 21:13:52 1996
***************
*** 256,261 ****
--- 256,283 ----
(set-buffer gnus-group-buffer)
(gnus-group-get-new-news)))))
+ (defun gnus-demon-add-scan-timestamps ()
+ "Add daemonic updating of timestamps in empty newgroups."
+ (gnus-demon-add-handler 'gnus-demon-scan-timestamps nil 30))
+
+ (defun gnus-demon-scan-timestamps ()
+ "Set the timestamp on all newsgroups with no unread and no ticked
+ articles."
+ (when (gnus-alive-p)
+ (let ((cur-time (current-time))
+ (newsrc (cdr gnus-newsrc-alist))
+ info group unread has-ticked)
+ (while (setq info (pop newsrc))
+ (setq group (gnus-info-group info)
+ unread (gnus-group-unread group)
+ has-ticked (cdr (assq 'tick (gnus-info-marks info))))
+ (when (and (numberp unread)
+ (= unread 0)
+ (not has-ticked))
+ (gnus-group-set-parameter group 'timestamp cur-time)))
+ )))
+
+
(provide 'gnus-demon)
;;; gnus-demon.el ends here
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1996-11-11 5:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-11-11 5:32 timestamp hilighting David Moore
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).