Commit 37ce0144 authored by David Byers's avatar David Byers
Browse files

Fixed language bug. Fixed bug 260 (ask for unread when joining).

Detailed changes:
> 	Fix bug 260:
> 	* commands1.el (kom-add-self): Ask for number of unread.
> 	 (lyskom-try-add-member): Show no-of-unread in text.
> 	 (lyskom-add-member-answer): Set unread if requested.
>
> 	* lyskom-rest.el (lyskom-read-num-range-or-date): Added initial,
> 	empty and default arguments.
>
> 	Language-dependent variables were set incorrectly in all but the
> 	first session:
> 	* startup.el (kom-start-anew): Unconditionally set the language,
> 	even if it looks like we're already on the right page.
>
> 	* language.el (lyskom-set-language-vars): When setting the
> 	language globally, muck with the default values of variables too.
>
parent a8c9ceb0
2003-03-16 David Byers <david.byers@swipnet.se>
Fix bug 260:
* commands1.el (kom-add-self): Ask for number of unread.
(lyskom-try-add-member): Show no-of-unread in text.
(lyskom-add-member-answer): Set unread if requested.
* lyskom-rest.el (lyskom-read-num-range-or-date): Added initial,
empty and default arguments.
Language-dependent variables were set incorrectly in all but the
first session:
* startup.el (kom-start-anew): Unconditionally set the language,
even if it looks like we're already on the right page.
* language.el (lyskom-set-language-vars): When setting the
language globally, muck with the default values of variables too.
Fix bug 859:
* swedish-strings.el,english-string.el (lyskom-messages): Fixed
show-membership-info-q.
......
......@@ -555,7 +555,10 @@ for confirmation."
'(all) nil nil t))
(pers-stat (blocking-do 'get-pers-stat (conf-stat->conf-no who))))
(lyskom-add-member-answer (lyskom-try-add-member whereto who
pers-stat nil nil t)
pers-stat
nil
nil
t)
whereto who)))
......@@ -578,8 +581,18 @@ See `kom-membership-default-priority' and
'(all) nil "" t)))
(who (blocking-do 'get-conf-stat lyskom-pers-no))
(pers-stat (blocking-do 'get-pers-stat lyskom-pers-no))
(mship (lyskom-get-membership (conf-stat->conf-no whereto) t)))
(mship (lyskom-get-membership (conf-stat->conf-no whereto) t))
(no-of-unread
(unless (and mship (not (membership-type->passive
(membership->type mship))))
(lyskom-read-num-range-or-date
0
(conf-stat->no-of-texts whereto)
(lyskom-format 'initial-unread)
nil
t
nil))))
;; Fake kom-membership-default-priority if this is a passive membership
;; This will suppress the normal "which priority" question. Ugly hack.
......@@ -587,8 +600,17 @@ See `kom-membership-default-priority' and
(if (and mship (membership-type->passive (membership->type mship)))
(membership->priority mship)
kom-membership-default-priority)))
(lyskom-add-member-answer (lyskom-try-add-member whereto who pers-stat nil nil t)
whereto who))))
(lyskom-add-member-answer (lyskom-try-add-member whereto
who
pers-stat
nil
nil
t
nil
no-of-unread)
whereto who
no-of-unread))))
(def-kom-command kom-change-priority (&optional conf)
......@@ -639,7 +661,8 @@ for person PERS-NO and send them into lyskom-try-add-member."
membership-type
&optional message-string
need-extra-information
default-priority)
default-priority
no-of-unread)
"Add a member to a conference.
Args: CONF-CONF-STAT PERS-CONF-STAT PERS-STAT
CONF-CONF-STAT: the conf-stat of the conference the person is being added to
......@@ -655,6 +678,19 @@ is the position where the membership was placed.
If optional USE-PRIORITY is non-nil then use that as the priority.
"
(cond ((null no-of-unread))
((numberp no-of-unread)
(setq no-of-unread (lyskom-format 'member-in-conf-with-unread
no-of-unread)))
((listp no-of-unread)
(setq no-of-unread
(lyskom-format 'member-in-conf-with-unread-date
(elt no-of-unread 0)
(car (rassq (elt no-of-unread 1)
lyskom-month-names))
(elt no-of-unread 2)))))
(if (or (null conf-conf-stat)
(null pers-conf-stat))
nil ; We have some problem here.
......@@ -724,7 +760,8 @@ If optional USE-PRIORITY is non-nil then use that as the priority.
(if (= (conf-stat->conf-no pers-conf-stat)
lyskom-pers-no)
(lyskom-format-insert 'member-in-conf
conf-conf-stat)
conf-conf-stat
no-of-unread)
(lyskom-format-insert 'add-member-in
pers-conf-stat
conf-conf-stat)))
......@@ -740,8 +777,10 @@ If optional USE-PRIORITY is non-nil then use that as the priority.
res))))))
(defun lyskom-add-member-answer (answer conf-conf-stat
pers-conf-stat)
(defun lyskom-add-member-answer (answer
conf-conf-stat
pers-conf-stat
&optional no-of-unread)
"Handle the result from an attempt to add a member to a conference."
(let ((pos (if (consp answer) (elt answer 1) nil))
(answer (if (consp answer) (elt answer 0) answer)))
......@@ -780,17 +819,31 @@ If optional USE-PRIORITY is non-nil then use that as the priority.
(cache-del-pers-stat (conf-stat->conf-no pers-conf-stat))
;;+++Borde {ndra i cachen i st{llet.
(cache-del-conf-stat (conf-stat->conf-no conf-conf-stat))
(if (= (conf-stat->conf-no pers-conf-stat)
(when (= (conf-stat->conf-no pers-conf-stat)
lyskom-pers-no)
(let ((mship (blocking-do 'query-read-texts
lyskom-pers-no
(conf-stat->conf-no conf-conf-stat)
t 0)))
(unless (membership->position mship)
(set-membership->position mship pos))
(when no-of-unread
(cond ((listp no-of-unread)
(let* ((target-date (lyskom-create-time 0 0 0 (elt no-of-unread 2) (elt no-of-unread 1) (elt no-of-unread 0) 0 0 nil))
(text (lyskom-find-text-by-date conf-conf-stat target-date)))
(when text
(blocking-do 'set-last-read
(conf-stat->conf-no conf-conf-stat)
(car text)))))
((numberp no-of-unread)
(blocking-do 'set-unread (conf-stat->conf-no conf-conf-stat)
no-of-unread))))
(let ((mship (blocking-do 'query-read-texts
lyskom-pers-no
(conf-stat->conf-no conf-conf-stat)
t 0)))
(unless (membership->position mship)
(set-membership->position mship pos))
(if (lyskom-try-get-membership (conf-stat->conf-no conf-conf-stat) t)
(progn (lyskom-replace-membership mship)
(lyskom-fetch-start-of-map conf-conf-stat mship))
(lyskom-add-membership mship
conf-conf-stat
t)))
t))))
(lyskom-insert-string 'done))))
......
......@@ -446,7 +446,9 @@ and you have finished reading. Please come back later.
(text-has-no-recipients-r . "Text %#1n has no recipients\n")
(where-on-list-q . "Placement in your list? (0-%#1d) ")
(member-in-conf . "Joining to %#1M...")
(member-in-conf . "Joining to %#1M%#2?b%[ %#2s%]%[%]...")
(member-in-conf-with-unread-date . "with unread from %#2s %#3d, %#1d")
(member-in-conf-with-unread . "unread %#1d unread")
(add-member-in . "Adding %#1P as a member of %#2M...")
(change-priority-for-q . "Change priority of conference: ")
(change-priority-for . "Changing priority of %#2M...")
......@@ -708,6 +710,7 @@ Read all about it at http://www.lysator.liu.se/history/")
The message you were sending to %#1M was:
%#2t\n")
(only-last . "Last texts in %#1s: ")
(initial-unread . "Initial number of unread (empty for all texts): ")
(only-error . "Something went wrong. Sorry.\n")
(you-have-unreads . "You have %#1d unread text%#1?d%[%]%[s%] in %#2M\n")
......@@ -1857,7 +1860,7 @@ environment to one that uses \"%#2s\" to encode text.
(or-date . "or date")
(set-unread-n . "Only read the most recent %#1?d%[text%]%[%#1d texts%].\n")
(set-unread-date . "Only read texts sinse %#2s %#3d, %#1d.\n")
(set-unread-date . "Only read texts since %#2s %#3d, %#1d.\n")
(jump-from-text . "Skip comments to which text? ")
(jumping-from-text . "Skipping comments to text %#1n.\n")
......
......@@ -82,7 +82,11 @@ sessions."
(lambda (spec)
(let ((var (car spec))
(var-scope (cdr spec)))
(when (or (eq scope 'global) (eq var-scope 'local))
(when (or (eq scope 'global)
(eq var-scope 'local))
(when (eq scope 'global)
(set-default var (eval (cdr (assq language
(get var 'lyskom-language-var))))))
(when (or (not (symbol-value var))
(get var 'lyskom-language-force))
(set var (eval (cdr (assq language
......
......@@ -3292,33 +3292,40 @@ message."
(lyskom-read-from-minibuffer prompt initial lyskom-verified-read-map))))
(defun lyskom-read-num-range-or-date (low high prompt)
(defun lyskom-read-num-range-or-date (low high prompt &optional initial empty default)
"Read a number or a date from the minibuffer.
Args: LOW HIGH PROMPT.
The result will be a number or a list of (YEAR MONTH DATE)."
(let ((result nil)
(val nil)
(break nil)
(val (and initial (number-to-string initial)))
(prompt (concat (if (symbolp prompt) (lyskom-get-string prompt) prompt)
(format "(%d-%d %s) " low high (lyskom-get-string 'or-date)))))
(while (null result)
(while (and (null result) (null break))
(setq val (lyskom-verified-read-from-minibuffer
prompt
val
(lambda (val)
(if (string-match "^\\s-*[0-9]+\\s-*$" val)
(let ((num (string-to-int val)))
(unless (and (>= num low) (<= num high))
(lyskom-get-string 'number-out-of-range)))
(condition-case nil
(progn (lyskom-parse-date val) nil)
(lyskom-error (lyskom-get-string 'invalid-date-entry)))))))
(if (string-match "^\\s-*[0-9]+\\s-*$" val)
(let ((num (string-to-int val)))
(when (and (>= num low) (<= num high))
(setq result num)))
(condition-case nil
(setq result (lyskom-parse-date val) )
(lyskom-error nil))))
prompt
(and val (cons val 0))
(lambda (val)
(cond
((string-match "^\\s-*[0-9]+\\s-*$" val)
(let ((num (string-to-int val)))
(unless (and (>= num low) (<= num high))
(lyskom-get-string 'number-out-of-range))))
((and empty (string-match "^\\s-*$" val)) nil)
(t
(condition-case nil
(progn (lyskom-parse-date val) nil)
(lyskom-error (lyskom-get-string 'invalid-date-entry))))))))
(cond ((string-match "^\\s-*[0-9]+\\s-*$" val)
(let ((num (string-to-int val)))
(when (and (>= num low) (<= num high))
(setq result num))))
((and empty (string-match "^\\s-*$" val))
(setq break t
result default))
(t (condition-case nil
(setq result (lyskom-parse-date val) )
(lyskom-error nil)))))
result))
......
......@@ -640,15 +640,14 @@ shown to other users."
(when login-successful
(progn (clear-all-caches)
(unless (eq lyskom-language kom-default-language)
(when (lyskom-set-language kom-default-language 'local)
(unless lyskom-have-one-login
(lyskom-set-language kom-default-language 'global)
(lyskom-maybe-setq-default kom-default-language kom-default-language)
(setq-default lyskom-language kom-default-language))
(lyskom-format-insert-before-prompt
'language-set-to
(lyskom-language-name kom-default-language))))
(when (lyskom-set-language kom-default-language 'local)
(unless lyskom-have-one-login
(lyskom-set-language kom-default-language 'global)
(lyskom-maybe-setq-default kom-default-language kom-default-language)
(setq-default lyskom-language kom-default-language))
(lyskom-format-insert-before-prompt
'language-set-to
(lyskom-language-name kom-default-language)))
(setq lyskom-have-one-login t)))
(when ignored-user-area-vars
......
......@@ -437,7 +437,9 @@ du har l
(text-has-no-recipients-r . "Inlgg %#1n har inga mottagare\n")
(where-on-list-q . "Placering p listan? (0-%#1d) ")
(member-in-conf . "Bli medlem i %#1M...")
(member-in-conf . "Bli medlem i %#1M%#2?b%[ %#2s%]%[%]...")
(member-in-conf-with-unread-date . "med olsta frn %#3d %#2s %#1d")
(member-in-conf-with-unread . "med %#1d olsta")
(add-member-in . "Addera %#1P som medlem i %#2M...")
(change-priority-for-q . "ndra prioritet fr mte: ")
(change-priority-for . "ndra prioritet p %#2M...")
......@@ -722,6 +724,7 @@ Ditt alarmmeddelande l
Meddelandet du frskte snda till %#1M var:
%#2t\n")
(only-last . "Endast lsa senaste i %#1s: ")
(initial-unread . "Initialt antal olsta (tomt fr alla): ")
(only-error . "Ngot gick galet. Ledsen.\n")
(you-have-unreads . "Du har %#1d olst%#1?d%[%]%[a%] inlgg i %#2M\n")
......
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