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

Bug fixes, new date printing, enhances person status

parent 564ccd70
No preview for this file type
...@@ -341,6 +341,9 @@ otherwise: the conference is read with lyskom-completing-read." ...@@ -341,6 +341,9 @@ otherwise: the conference is read with lyskom-completing-read."
(pers-stat->username pers-stat)) (pers-stat->username pers-stat))
(lyskom-format-insert 'read-texts (lyskom-format-insert 'read-texts
(pers-stat->read-texts pers-stat)) (pers-stat->read-texts pers-stat))
(if (= (pers-stat->pers-no pers-stat) lyskom-pers-no)
(lyskom-format-insert 'marked-texts
(pers-stat->no-of-marks pers-stat)))
(lyskom-format-insert 'time-for-last-letter (lyskom-format-insert 'time-for-last-letter
(lyskom-return-time (lyskom-return-time
(conf-stat->last-written conf-stat))) (conf-stat->last-written conf-stat)))
...@@ -481,10 +484,10 @@ otherwise: the conference is read with lyskom-completing-read." ...@@ -481,10 +484,10 @@ otherwise: the conference is read with lyskom-completing-read."
message)) message))
(def-kom-command kom-send-alarm () (def-kom-command kom-send-alarm (&optional message)
"Send a message to all of the users in KOM right now." "Send a message to all of the users in KOM right now."
(interactive) (interactive)
(lyskom-send-message 0 nil)) (lyskom-send-message 0 message))
(defun lyskom-send-message (pers-no message) (defun lyskom-send-message (pers-no message)
...@@ -519,29 +522,30 @@ means send the message to everybody." ...@@ -519,29 +522,30 @@ means send the message to everybody."
;;; Author: Linus Tolke ;;; Author: Linus Tolke
(def-kom-command kom-set-unread (&optional arg) (def-kom-command kom-set-unread (&optional arg conf-no)
"Set number of unread articles in current conference." "Set number of unread articles in current conference."
(interactive "P") (interactive "P")
(if (zerop lyskom-current-conf) (if (and (zerop lyskom-current-conf) (null conf-no))
(lyskom-insert-string 'not-present-anywhere) (lyskom-insert-string 'not-present-anywhere)
(let ((conf-stat (blocking-do 'get-conf-stat lyskom-current-conf))) (let ((conf-stat (blocking-do 'get-conf-stat (or conf-no
(if (null conf-stat) ;+++ annan errorhantering lyskom-current-conf))))
(lyskom-insert "Error!\n") ;+++ Hrrrmmmmffff???? (if (null conf-stat) ;+++ annan errorhantering
(let* ((narg (prefix-numeric-value arg)) (lyskom-insert "Error!\n") ;+++ Hrrrmmmmffff????
(n (if (and arg (let* ((narg (prefix-numeric-value arg))
(<= 0 narg) (n (if (and arg
(<= narg (conf-stat->no-of-texts conf-stat))) (<= 0 narg)
narg (<= narg (conf-stat->no-of-texts conf-stat)))
(lyskom-read-num-range narg
0 (conf-stat->no-of-texts conf-stat) (lyskom-read-num-range
(lyskom-format 'only-last 0 (conf-stat->no-of-texts conf-stat)
(conf-stat->no-of-texts conf-stat) (lyskom-format 'only-last
(conf-stat->name conf-stat))))) (conf-stat->no-of-texts conf-stat)
(result (blocking-do 'set-unread (conf-stat->name conf-stat)))))
(conf-stat->conf-no conf-stat) n))) (result (blocking-do 'set-unread
(if (null result) (conf-stat->conf-no conf-stat) n)))
(lyskom-insert-string 'only-error) (if (null result)
(lyskom-refetch))))))) (lyskom-insert-string 'only-error)
(lyskom-refetch)))))))
...@@ -560,40 +564,40 @@ means send the message to everybody." ...@@ -560,40 +564,40 @@ means send the message to everybody."
(interactive "P") (interactive "P")
(lyskom-prefetch-all-confs) (lyskom-prefetch-all-confs)
(let ((num-arg (cond (let ((num-arg (cond
((numberp num) num) ((numberp num) num)
((and (listp num) ((and (listp num)
(numberp (car num))) (car num)) (numberp (car num))) (car num))
(t nil))) (t nil)))
(sum 0)) (sum 0))
(mapcar (mapcar
(function (function
(lambda (info) (lambda (info)
(let ((un (length (cdr (read-info->text-list info)))) (let ((un (length (cdr (read-info->text-list info))))
(name (conf-stat->name (read-info->conf-stat info))) (name (conf-stat->name (read-info->conf-stat info)))
(conf-stat (read-info->conf-stat info))) (conf-stat (read-info->conf-stat info)))
(cond (cond
((eq (read-info->type info) 'CONF) ((eq (read-info->type info) 'CONF)
(if (or (not num-arg) (if (or (not num-arg)
(>= (-- num-arg) 0)) (>= (-- num-arg) 0))
(lyskom-insert (lyskom-insert
(if (and (boundp 'lyskom-special-conf-name) (if (and (boundp 'lyskom-special-conf-name)
(stringp lyskom-special-conf-name) (stringp lyskom-special-conf-name)
(string-match lyskom-special-conf-name name)) (string-match lyskom-special-conf-name name))
(if (/= un 1) (if (/= un 1)
(lyskom-format 'you-have-unreads-special un conf-stat) (lyskom-format 'you-have-unreads-special un conf-stat)
(lyskom-format 'you-have-an-unread-special conf-stat)) (lyskom-format 'you-have-an-unread-special conf-stat))
(if (/= un 1) (if (/= un 1)
(lyskom-format 'you-have-unreads un conf-stat) (lyskom-format 'you-have-unreads un conf-stat)
(lyskom-format 'you-have-an-unread conf-stat))))) (lyskom-format 'you-have-an-unread conf-stat)))))
(setq sum (+ sum un))))))) (setq sum (+ sum un)))))))
(read-list->all-entries lyskom-to-do-list)) (read-list->all-entries lyskom-to-do-list))
(if (= 0 sum) (if (= 0 sum)
(lyskom-insert-string 'you-have-read-everything) (lyskom-insert-string 'you-have-read-everything)
(lyskom-insert (lyskom-insert
(if (/= sum 1) (if (/= sum 1)
(lyskom-format 'total-unreads (lyskom-format 'total-unreads
sum) sum)
(format (lyskom-get-string 'total-unread))))))) (format (lyskom-get-string 'total-unread)))))))
;;; ================================================================ ;;; ================================================================
......
...@@ -380,6 +380,7 @@ and you have finished reading. Please come back later. ...@@ -380,6 +380,7 @@ and you have finished reading. Please come back later.
(user-name . "User: %36#1s\n") (user-name . "User: %36#1s\n")
(read-texts . "Articles read:%28#1d\n") (read-texts . "Articles read:%28#1d\n")
(marked-texts . "Articles marked:%26#1d")
(time-for-last-letter . "Time of last letter:%22#1s (accordning to your cache)\n") (time-for-last-letter . "Time of last letter:%22#1s (accordning to your cache)\n")
(superconf . "%[%#3@Superconference:%31#1:m%] %#4s(%#2M)\n") (superconf . "%[%#3@Superconference:%31#1:m%] %#4s(%#2M)\n")
(supervisor . "%[%#3@Supervisor:%29#1:p%] %#4s(%#2P)\n") (supervisor . "%[%#3@Supervisor:%29#1:p%] %#4s(%#2P)\n")
...@@ -552,6 +553,10 @@ Mark the envelope with \"LysKOM bug report\"\n\n") ...@@ -552,6 +553,10 @@ Mark the envelope with \"LysKOM bug report\"\n\n")
; used by lyskom-print-time ; used by lyskom-print-time
(time-y-m-d-h-m . "%4#1d %02#3d/%02#1d %02#4d:%02#5d ") (time-y-m-d-h-m . "%4#1d %02#3d/%02#1d %02#4d:%02#5d ")
(today-time-format-string . "%#6s %02#4d:%02#5d")
(yesterday-time-format-string . "%#6s %02#4d:%02#5d")
(today . "today")
(yesterday . "yesterday")
; used by lyskom-return-time ; used by lyskom-return-time
(time-yyyy-mm-dd-hh-mm . "%4#1d %02#3d/%02#2d %02#4d:%02#5d") (time-yyyy-mm-dd-hh-mm . "%4#1d %02#3d/%02#2d %02#4d:%02#5d")
(no-such-text-no . "The article doesn't exist. (%#1d)\n") (no-such-text-no . "The article doesn't exist. (%#1d)\n")
......
...@@ -390,6 +390,7 @@ du har l\344st klart allting. Kom tillbaks senare. ...@@ -390,6 +390,7 @@ du har l\344st klart allting. Kom tillbaks senare.
(user-name . "Anv\344ndare: %30#1s\n") (user-name . "Anv\344ndare: %30#1s\n")
(read-texts . "L\344sta texter:%28#1d\n") (read-texts . "L\344sta texter:%28#1d\n")
(marked-texts . "Markerade texter:%24#1d\n")
(time-for-last-letter . "Tid f\366r senaste brev:%20#1s (st\345r det i din cache)\n") (time-for-last-letter . "Tid f\366r senaste brev:%20#1s (st\345r det i din cache)\n")
(superconf . "%[%#3@Superm\366te:%31#1:m%] %#4s(%#2M)\n") (superconf . "%[%#3@Superm\366te:%31#1:m%] %#4s(%#2M)\n")
(supervisor . "%[%#3@Organisat\366r:%29#1:p%] %#4s(%#2P)\n") (supervisor . "%[%#3@Organisat\366r:%29#1:p%] %#4s(%#2P)\n")
...@@ -579,6 +580,10 @@ M\344rk kuvertet \"LysKOM buggrapport f\366r elispklienten\".\n\n") ...@@ -579,6 +580,10 @@ M\344rk kuvertet \"LysKOM buggrapport f\366r elispklienten\".\n\n")
; used by lyskom-print-time ; used by lyskom-print-time
(time-y-m-d-h-m . "%4#1d-%02#2d-%02#3d %02#4d:%02#5d ") (time-y-m-d-h-m . "%4#1d-%02#2d-%02#3d %02#4d:%02#5d ")
(today-time-format-string . "%#6s %02#4d:%02#5d")
(yesterday-time-format-string . "%#6s %02#4d:%02#5d")
(today . "idag")
(yesterday . "igr")
; used by lyskom-return-time ; used by lyskom-return-time
(time-yyyy-mm-dd-hh-mm . "%4#1d-%02#2d-%02#3d %02#4d:%02#5d") (time-yyyy-mm-dd-hh-mm . "%4#1d-%02#2d-%02#3d %02#4d:%02#5d")
(no-such-text-no . "Det finns ingen s\345dan text. (%#1n)\n") (no-such-text-no . "Det finns ingen s\345dan text. (%#1n)\n")
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
;;;; ================================================================ ;;;; ================================================================
;;;; Emacs dependant variables ;;;; Emacs dependant variables
(defvar kom-emacs-knows-iso-8859-1 nil (defvar kom-emacs-knows-iso-8859-1 t
"*If non-nil then dont convert texts and other things to swascii. "*If non-nil then dont convert texts and other things to swascii.
This variable is not saved. It should be set in your .emacs") This variable is not saved. It should be set in your .emacs")
...@@ -216,54 +216,58 @@ various LysKOM elements.") ...@@ -216,54 +216,58 @@ various LysKOM elements.")
'((text '((text
text-text text-text
lyskom-button-view-text lyskom-button-view-text
((kom-view "Återse" . lyskom-button-view-text) (("Återse texten" . lyskom-button-view-text)
(kom-write-comment "Kommentera" . lyskom-button-comment-text) ("Kommentera texten" . lyskom-button-comment-text)
(kom-private-answer "Personligt svar" . lyskom-button-private-comment-text) ("Personligt svar" . lyskom-button-private-comment-text)
(kom-mark-text "Markera" . lyskom-button-mark-text) ("Markera texten" . lyskom-button-mark-text)
(kom-unmark-text "Avmarkera" . lyskom-button-unmark-text)) ("Avmarkera texten" . lyskom-button-unmark-text))
nil) nil)
(conf (conf
conf-text conf-text
lyskom-button-view-conf-presentation lyskom-button-view-conf-presentation
((kom-view-presentation "Återse presentation" . (("Visa presentation" . lyskom-button-view-conf-presentation)
lyskom-button-view-conf-presentation) ("Visa mötesstatus" . lyskom-button-view-conf-status)
(kom-status-conf "Visa status" . lyskom-button-view-conf-status) ("Gå till mötet" . lyskom-button-goto-conf)
(kom-go-to-conf "Gå till mötet" . lyskom-button-goto-conf)) ("Bli medlem i mötet" . lyskom-button-add-self)
("Utträd ur mötet" . lyskom-button-sub-self))
((kom-list-news . lyskom-button-goto-conf))) ((kom-list-news . lyskom-button-goto-conf)))
(pers (pers
pers-text pers-text
lyskom-button-view-pers-presentation lyskom-button-view-pers-presentation
((kom-view-presentation "Återse presentation" . (("Visa presentation" .
lyskom-button-view-pers-presentation) lyskom-button-view-pers-presentation)
(kom-status-person "Visa status" . lyskom-button-view-pers-status) ("Visa personstatus" . lyskom-button-view-pers-status)
(kom-send-letter "Skicka brev" . lyskom-button-mail)) ("Skicka brev" . lyskom-button-mail)
("Sänd meddelande" . lyskom-button-send-message))
nil) nil)
(url (url
url-text url-text
lyskom-button-open-url lyskom-button-open-url
((kom-open-url "Öppna" . lyskom-button-open-url) (("Öppna" . lyskom-button-open-url)
(kom-copy-url "Kopiera" . lyskom-button-copy-url)) ("Kopiera" . lyskom-button-copy-url))
nil)) nil))
"This variable defines valid button types in LysKOM. Each element is a "This variable defines valid button types in LysKOM. Each element is a
list consisting of TYPE LABEL DEFAULT ACTIONS HINTS. list consisting of (TYPE LABEL DEFAULT ACTIONS HINTS).
TYPE is the button type the entry defines TYPE is the button type the entry defines
LABEL is a textual representation for the button type, used in menu titles. If LABEL is a textual representation for the button type, used in menu titles. If
it is a symbol, that symbol will be looked up using lyskom-get-string. it is a symbol, that symbol will be looked up using lyskom-get-string.
DEFAULT is the default action to take on a click. It must be a function. DEFAULT is the default action to take on a click. It must be a function.
ACTIONS are other possible actions. The format of this entry is described below. ACTIONS are other possible actions. The format of this entry is described
HINTS is a list of hints to override the default action. This is described below. below.
HINTS is a list of hints to override the default action. This is described
below.
The ACTIONS entry is used to construct a pop-up menu. It is a list consisting of The ACTIONS entry is used to construct a pop-up menu. It is a list consisting
lists with the format (COMMAND STRING . FUNCTION). COMMAND is used to distinguish of lists with the format (STRING . FUNCTION). STRING is the menu label and
the elements of the menu, STRING is the menu label and FUNCTION is the function to FUNCTION is the function to call when the menu item is selected.
call when the menu item is selected.
The HINTS entry is used to generate hints that the default action should be The HINTS entry is used to generate hints that the default action should be
overridden. It is a list containing elements (COMMAND . HINT) where COMMAND is overridden. It is a list containing elements (COMMAND . HINT) where COMMAND is
as interactive LysKOM command and HINT is a function to call. When a button as interactive LysKOM command and HINT is a function to call. When a button
is generated while the command COMMAND is being executed, HINT is used as a hint is generated while the command COMMAND is being executed, HINT is used as a
for a new default action. The user has the option to ignore or used the hint.") hint for a new default action. The user has the option to ignore or used the
hint.")
(defvar lyskom-text-buttons (defvar lyskom-text-buttons
...@@ -344,6 +348,9 @@ he gets a y-or-n-p question for all recipients.") ...@@ -344,6 +348,9 @@ he gets a y-or-n-p question for all recipients.")
(defvar kom-max-buffer-size nil (defvar kom-max-buffer-size nil
"*If non-nil, ensure that buffers won't grow any larger than this") "*If non-nil, ensure that buffers won't grow any larger than this")
(defvar lyskom-print-complex-dates t
"*If non-nil, print today and yesterday using a special format.")
(defvar lyskom-server-aliases (defvar lyskom-server-aliases
'(("kom.lysator.liu.se" . "LysKOM") '(("kom.lysator.liu.se" . "LysKOM")
("kom.ludd.luth.se" . "LuddKOM") ("kom.ludd.luth.se" . "LuddKOM")
......
...@@ -295,14 +295,45 @@ recipients to it that the user is a member in." ...@@ -295,14 +295,45 @@ recipients to it that the user is a member in."
res)) res))
(defun lyskom-subtract-one-day (x)
(let ((high-x (1- (car x)))
(low-x (car (cdr x))))
(if (> 20864 low-x)
(setq high-x (1- high-x)
low-x (+ low-x 65536)))
(setq low-x (- low-x 20864))
(list high-x low-x nil)))
(defun lyskom-calculate-day-diff (time)
(let* ((now (current-time))
(yesterday (lyskom-subtract-one-day now))
(decnow (decode-time now))
(decthen (decode-time yesterday)))
(cond ((and (= (time->mday time) (elt decnow 3))
(= (1+ (time->mon time)) (elt decnow 4))
(= (+ (time->year time) 1900) (elt decnow 5)))
'today)
((and (= (time->mday time) (elt decthen 3))
(= (1+ (time->mon time)) (elt decthen 4))
(= (+ (time->year time) 1900) (elt decthen 5)))
'yesterday)
(t nil))))
(defun lyskom-print-date-and-time (time) (defun lyskom-print-date-and-time (time)
"Print date and time. Arg: TIME." "Print date and time. Arg: TIME."
(lyskom-format-insert 'time-y-m-d-h-m (let* ((diff (lyskom-calculate-day-diff time)))
(+ (time->year time) 1900) (lyskom-format-insert
(1+ (time->mon time)) (if (and diff lyskom-print-complex-dates)
(time->mday time) (intern (concat (symbol-name diff) "-time-format-string"))
(time->hour time) 'time-y-m-d-h-m)
(time->min time))) (+ (time->year time) 1900)
(1+ (time->mon time))
(time->mday time)
(time->hour time)
(time->min time)
(and diff (lyskom-get-string diff)))))
(defun lyskom-print-text (text-stat text mark-as-read text-no) (defun lyskom-print-text (text-stat text mark-as-read text-no)
......
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