Commit 43038725 authored by David Byers's avatar David Byers
Browse files

Better support for change conf hooks.

Bug fixes: can change presentation even when old one is missing and
can handle prehistoric dates on imported e-mails (calendar reported
negative day-of-week)
parent b69cac0b
2001-05-24 David Byers <davby@ida.liu.se>
* vars.el.in (lyskom-after-change-conf-hook): New hook.
* commands1.el (lyskom-go-to-empty-conf): Call
lyskom-after-change-conf-hook.
* commands2.el: Use new lyskom-list-summary.
(lyskom-list-summary): New function generalizes kom-list-summary.
(lyskom-do-list-summary): New name for old lyskom-list-summary.
* utilities.el (lyskom-run-hook-with-args): Use
lyskom-save-excursion, not save-excursion, so printing moves point
properly in hooks.
* lyskom-rest.el (lyskom-enter-conf): Add
lyskom-after-change-conf-hook. Use to-conf and from-conf.
2001-05-23 David Byers <davby@ida.liu.se>
* commands1.el: Change presentation works even if the old
presentation has been deleted.
2001-05-22 David Byers <davby@ida.liu.se>
* view-text.el (lyskom-mx-date-to-time): Deal with really strange
dates that result in negative day numbers.
* commands1.el (kom-review-presentation): Print FAQs as if they
were comments.
(lyskom-print-comment-like-aux): New function.
......
......@@ -1346,7 +1346,8 @@ TYPE is either 'pres or 'motd, depending on what should be changed."
(apply
'lyskom-create-misc-list
(if (and (eq type 'pres)
(not (zerop (conf-stat->presentation conf-stat))))
(not (or (zerop (conf-stat->presentation conf-stat))
(null text-stat))))
(append
(lyskom-get-recipients-from-misc-list
(text-stat->misc-info-list text-stat))
......@@ -1514,7 +1515,10 @@ Args: CONF-STAT MEMBERSHIP"
(conf-stat->conf-no conf-stat))
(setq lyskom-current-conf (conf-stat->conf-no conf-stat))
(lyskom-format-insert 'conf-all-read
conf-stat))
conf-stat)
(lyskom-run-hook-with-args 'lyskom-after-change-conf-hook
lyskom-current-conf
(conf-stat->conf-no conf-stat)))
......
......@@ -939,23 +939,36 @@
(interactive)
(if (read-list-isempty lyskom-reading-list)
(lyskom-insert-string 'have-to-be-in-conf-with-unread)
(lyskom-list-summary
(text-list->texts
(read-info->text-list
(let ((len (read-list-length lyskom-reading-list))
(r 0))
(while (< r len)
(let ((type (read-info->type
(read-list->nth lyskom-reading-list
r))))
(if (memq type '(CONF REVIEW-MARK REVIEW))
(setq len 0)
(++ r))))
(read-list->nth lyskom-reading-list r)))))))
(defun lyskom-list-summary (texts)
(lyskom-list-summary nil)))
(defun lyskom-list-summary (conf-no)
"List a summary of unread texts in conference CONF-NO.
If CONF-NO is nil, list the first text-list element in lyskom-reading-list.
The summary contains the date, number of lines, author and subject of
the text on one line."
(let* ((read-info nil)
(read-list (if conf-no lyskom-to-do-list lyskom-reading-list))
(len (read-list-length read-list))
(r 0))
(while (< r len)
(if (or (and conf-no
(eq (read-info->type (read-list->nth read-list r)) 'CONF)
(eq conf-no (conf-stat->conf-no
(read-info->conf-stat
(read-list->nth read-list r)))))
(and (null conf-no)
(memq (read-info->type (read-list->nth read-list r))
'(CONF REVIEW-MARK REVIEW))))
(setq len 0)
(setq r (1+ r))))
(setq read-info (read-list->nth read-list r))
(when read-info
(lyskom-do-list-summary
(text-list->texts (read-info->text-list read-info))))
))
(defun lyskom-do-list-summary (texts)
"List a summary of the texts in TEXTS.
The summary contains the date, number of lines, author and subject of the text
on one line."
......
......@@ -613,28 +613,37 @@ If CONF is nil, check the first conf on the to-do list."
Prints the name and amount of unread in the conference we just went to
according to the value of kom-print-number-of-unread-on-entrance.
Args: CONF-STAT READ-INFO"
(lyskom-run-hook-with-args 'lyskom-change-conf-hook
lyskom-current-conf
(conf-stat->conf-no conf-stat))
(unless lyskom-is-anonymous
(initiate-pepsi 'main nil (conf-stat->conf-no conf-stat)))
(setq lyskom-current-conf (conf-stat->conf-no conf-stat))
(let ((num-unread (text-list->length (read-info->text-list read-info))))
(lyskom-format-insert (if (not kom-print-number-of-unread-on-entrance)
'enter-conf
(if (= num-unread 1)
'one-unread
'several-unread))
conf-stat
num-unread)))
(let ((from-conf lyskom-current-conf)
(to-conf (conf-stat->conf-no conf-stat)))
(lyskom-run-hook-with-args 'lyskom-change-conf-hook
from-conf
to-conf)
(unless lyskom-is-anonymous
(initiate-pepsi 'main nil to-conf))
(setq lyskom-current-conf to-conf)
(let ((num-unread (text-list->length (read-info->text-list read-info))))
(lyskom-format-insert (if (not kom-print-number-of-unread-on-entrance)
'enter-conf
(if (= num-unread 1)
'one-unread
'several-unread))
conf-stat
num-unread)
(lyskom-run-hook-with-args 'lyskom-after-change-conf-hook
from-conf
to-conf))))
(defun lyskom-leave-current-conf ()
"Leave the current conference without going to another one."
(set-read-list-empty lyskom-reading-list)
(lyskom-run-hook-with-args 'lyskom-change-conf-hook
lyskom-current-conf 0)
(setq lyskom-current-conf 0)
(initiate-pepsi 'main nil 0))
(let ((from-conf lyskom-current-conf))
(set-read-list-empty lyskom-reading-list)
(lyskom-run-hook-with-args 'lyskom-change-conf-hook
from-conf 0)
(setq lyskom-current-conf 0)
(initiate-pepsi 'main nil 0)
(lyskom-run-hook-with-args 'lyskom-after-change-conf-hook
from-conf 0)
))
;;;================================================================
......
......@@ -722,9 +722,9 @@ The order of the list a is kept."
(defun lyskom-run-hook-with-args (hook &rest args)
"Run HOOK with the specified arguments ARGS in the LysKOM buffer.
See run-hook-with-args for detailed information."
(save-excursion (set-buffer (or (and (boundp 'lyskom-buffer)
lyskom-buffer)
(current-buffer)))
(lyskom-save-excursion (set-buffer (or (and (boundp 'lyskom-buffer)
lyskom-buffer)
(current-buffer)))
(apply 'run-hook-with-args hook args)))
......
......@@ -487,7 +487,19 @@ signal success and nil to prevent the text from being sent."
(def-kom-var lyskom-change-conf-hook nil
"*Hook to run when changing conferences.
The functions in this list are run with two arguments. The first is the
current conf-no and the second is the conf-no being changed to."
current conf-no and the second is the conf-no being changed to.
This hook is run before lyskom-current-conf is changed, and before any
standard messages have been printed."
local-hook)
(def-kom-var lyskom-after-change-conf-hook nil
"*Hook to run when changing conferences.
The functions in this list are run with two arguments. The first is the
current conf-no and the second is the conf-no being changed to.
This hook is run after lyskom-current-conf is changed, and after any
standard messages have been printed."
local-hook)
(def-kom-var lyskom-login-hook nil
......
......@@ -1195,11 +1195,12 @@ Returns the time structure if successful, otherwise nil."
(year (string-to-number (match-string 1 (aux-item->data mx-date))))
(tzhr (match-string 7 (aux-item->data mx-date)))
(tzmin (or (match-string 8 (aux-item->data mx-date)) ""))
(wday (elt
(calendar-iso-from-absolute
(calendar-absolute-from-gregorian
(list mon mday year)))
1)))
(wday (abs
(elt
(calendar-iso-from-absolute
(calendar-absolute-from-gregorian
(list mon mday year)))
1))))
(lyskom-create-time secs mins hour mday mon year wday 0 nil tzhr tzmin))))
;;; Local Variables:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment