Commit 1ff95867 authored by David Byers's avatar David Byers
Browse files

Ny completing-read, småfel i filter.el, ansaphone.el, vars.el

parent ca8d65ca
Mon Jul 8 10:37:48 1996 David Byers <davby@sen2.ida.liu.se>
* filter.el (kom-super-jump): Vljer mottagare att filtrera som
aktuellt mte om inlgget har aktuellt mte som mottagare, annars
inlggets frsta mottagare.
* english-strings.el, swedish-strings.el (lyskom-strings): Lade
till no-recipient.
Thu Jul 4 14:10:36 1996 David Byers <davby@sen2.ida.liu.se>
* completing-read.el: Totalt omskriven. Strre, kanske
lngsammare, men jag vet hur den fungerar nu.
(lyskom-read-conf-no): Ny betydelse av PREDICATE-parametern.
(lyskom-read-conf-stat): Ny parameterlista (nytt PREDICATE,
MUSTMATCH tillagt.)
(lyskom-read-conf-name): Nu parameterlista. Ny ordning, lagt till
EMPTY-parametern.
(lyskom-read-conf-internal): Ny funktion som gr allt jobb.
(lyskom-read-conf-name-internal): Utbytt mot
lyskom-read-conf-internal.
(lyskom-read-conf-get-logins, lyskom-read-conf-expand-specials,
lyskom-read-conf-lookup-specials, lyskom-lookup-conf-by-name,
lyskom-complete-collect, lyskom-read-conf-internal-verify-type,
lyskom-complete-string, lyskom-complete-string-up-level,
lyskom-complete-string-skip-parens-backup-others,
lyskom-complete-string-skip-parens-2,
lyskom-complete-string-next-word,
lyskom-complete-string-reset-position): Nya funktioner.
* startup.el (kom-start-anew): ndrade predicate-parametern till
lyskom-read-conf-nnting. Anvnd lyskom-lookup-conf-by-name.
* review.el (lyskom-review-by-to): ndrade predicate-parametern
till lyskom-read-conf-nnting.
* commands2.el (kom-status-conf, kom-status-person,
kom-send-message, kom-set-garb-nice, kom-set-permitted-submitters,
kom-set-super-conf, kom-change-conf-type): ndrade
predicate-parametern till lyskom-read-conf-nnting.
* edit-text.el (lyskom-edit-add-recipient/copy): ndrade
predicate-parametern till lyskom-read-conf-nnting.
* filter.el (kom-filter-subject, kom-filter-author,
kom-filter-text): ndrade predicate-parametern till
lyskom-read-conf-nnting.
* commands1.el (kom-delete-conf, kom-review-presentation,
kom-send-letter, kom-add-member, kom-add-self, kom-sub-member,
kom-sub-self, kom-change-presentation, kom-change-conf-motd,
kom-unset-conf-motd, kom-go-to-conf, kom-change-name,
kom-change-supervisor, kom-change-password,
lyskom-add-sub-recipient): ndrade predicate-parametern till
lyskom-read-conf-nnting.
* startup.el (kom-start-anew): Anropa lyskom-login-hook oxo. Den
sparas *inte* i servern.
* vars.el.in (lyskom-text-buttons): Ny definition av regexpen fr
textnummer.
Tue Jul 2 09:14:53 1996 David Kgedal <davidk@lysator.liu.se>
* lyskom-rest.el (lyskom-prefetch-comment-stats): Ny funktion.
......@@ -11,6 +74,18 @@ Sun Jun 23 02:16:23 1996 David K
* edit-text.el (lyskom-edit-parse-headers): Kr
lyskom-swascii-header-subject genom regexp-quote innan matchning.
Sat Jun 22 17:15:53 1996 David Byers <davby@sen2.ida.liu.se>
* ansaphone.el (lyskom-ansaphone-message-handler): Spara
meddelanden enbart om kom-ansaphone-record-messages r icke-nil
(request frn Tommy Persson). Visa inte alltid meddelanden som
spelas in.
* vars.el.in (lyskom-elisp-variables): Lade till
kom-ansaphone-record-messages och kom-ansaphone-show-messages.
(kom-ansaphone-record-messages): Ny variabel.
(kom-ansaphone-show-messages): Nu variabel.
Thu Jun 20 01:08:00 1996 David Kgedal <davidk@lysator.liu.se>
* async.el (lyskom-show-logged-in-person): Hantera hemliga
......
......@@ -3,7 +3,14 @@ Att g
Buggar
Completion-koden är ivägen när man vill skapa nya personer.
Completion bryr sig inte om MUSTMATCH-parametern.
Om KOMNAME är satt till "" så kommer completionkoden att försöka
komplettera det till alla personer. Det vill man *inte*.
Completion-koden är ivägen när man vill skapa nya personer. [Nåja,
inte så mycket. Det är bara att man inte får skapa namn som är
prefix till existerande namn]
Om man läser ett inlägg som har en fotnot (t ex 1449843) och vill
spara det på fil, så blir det bara fotnoten som sparas. Man vill
......@@ -22,11 +29,12 @@ Buggar
till nil. (FIXAT)
LysKOMs completing-read är skit. Den gör fel. Den borde skrivas om.
(FIXAT)
lyskom-try-complete-partials borde returnera exakta matchar före
längsta match. Nu blir (lyskom-try-complete-partials "link"
'(("(foo) link (bar)" . 1) ("linkfoobar" . 2))) "linkfoobar", inte
"(foo) link (bar)".
"(foo) link (bar)". (FUNKTIONEN ERSATT; FIXAT)
Om ett namn som fylls i i efterhand gör att raden blir för lång,
så scrollar klienten ibland trots att den inte borde.
......
......@@ -125,6 +125,11 @@ See kom-ansaphone-on"
(lyskom-set-current-message-text (substring text
(match-beginning 1)
(match-end 1)))))
;;
;; See if we want to reply to this message
;;
(if (and kom-ansaphone-on
sender
recipient
......@@ -144,11 +149,25 @@ See kom-ansaphone-on"
lyskom-ansaphone-when-set)
(elt reply 4)))
(lyskom-ansaphone-send-message sender reply)))))
(if (and kom-ansaphone-on sender)
;;
;; See if we want to record this message
;;
(if (and kom-ansaphone-on
kom-ansaphone-record-messages
sender)
(lyskom-ansaphone-record-message sender
recipient
lyskom-message-current-text)))
nil)
;;
;; Perhaps we want to show the message, perhaps not
;;
(if kom-ansaphone-on
(not kom-ansaphone-show-messages)
nil))
......
......@@ -70,7 +70,7 @@
(interactive)
(let ((conf-stat
(lyskom-read-conf-stat (lyskom-get-string 'what-conf-to-delete)
'all)))
'(all))))
(if conf-stat
(if (lyskom-ja-or-nej-p
(lyskom-format 'confirm-delete-pers-or-conf
......@@ -128,7 +128,7 @@
(blocking-do 'get-conf-stat who)
(lyskom-read-conf-stat
(lyskom-get-string 'presentation-for-whom)
'all))))
'(all)))))
(if (null conf-stat)
(lyskom-insert-string 'somebody-deleted-that-conf)
(lyskom-format-insert 'review-presentation-of
......@@ -236,7 +236,7 @@ as TYPE. If no such misc-info, return NIL"
(let* ((tono (or pers-no
(lyskom-read-conf-no
(lyskom-get-string 'who-letter-to)
'all nil nil t)))
'(all) nil nil t)))
(conf-stat (blocking-do 'get-conf-stat tono)))
(if (if (zerop (conf-stat->msg-of-day conf-stat))
t
......@@ -274,9 +274,9 @@ as TYPE. If no such misc-info, return NIL"
Ask for the name of the person, the conference to add him/her to."
(interactive)
(let* ((who (lyskom-read-conf-stat (lyskom-get-string 'who-to-add)
'pers))
'(pers)))
(whereto (lyskom-read-conf-stat (lyskom-get-string 'where-to-add)
'all))
'(all)))
(pers-stat (blocking-do 'get-pers-stat (conf-stat->conf-no who))))
(lyskom-add-member-answer (lyskom-try-add-member whereto who pers-stat)
whereto who)))
......@@ -291,7 +291,7 @@ Ask for the name of the person, the conference to add him/her to."
(let ((whereto (if conf (blocking-do 'get-conf-stat conf)
(lyskom-read-conf-stat
(lyskom-get-string 'where-to-add-self)
'all)))
'(all) nil "" t)))
(who (blocking-do 'get-conf-stat lyskom-pers-no))
(pers-stat (blocking-do 'get-pers-stat lyskom-pers-no)))
(lyskom-add-member-answer (lyskom-try-add-member whereto who pers-stat)
......@@ -455,9 +455,10 @@ Also adds to lyskom-to-do-list."
of the person."
(interactive)
(lyskom-sub-member
(lyskom-read-conf-stat (lyskom-get-string 'who-to-exclude) 'pers nil "")
(lyskom-read-conf-stat (lyskom-get-string 'who-to-exclude)
'(pers) nil "")
(lyskom-read-conf-stat (lyskom-get-string 'where-from-exclude)
'all nil "")))
'(all) nil "")))
(def-kom-command kom-sub-self (&optional conf)
......@@ -467,7 +468,7 @@ of the person."
(blocking-do 'get-conf-stat lyskom-pers-no)
(if conf (blocking-do 'get-conf-stat conf)
(lyskom-read-conf-stat (lyskom-get-string 'leave-what-conf)
'all nil
'(all) nil
(let ((ccn
(if (or (zerop lyskom-current-conf))
""
......@@ -913,7 +914,7 @@ Don't ask for confirmation."
(lyskom-change-pres-or-motd-2
(let ((no (lyskom-read-conf-no
(lyskom-get-string 'what-to-change-pres-you)
'all t nil t)))
'(all) t nil t)))
(if (zerop no)
(setq no lyskom-pers-no))
(blocking-do 'get-conf-stat no))
......@@ -925,7 +926,7 @@ Don't ask for confirmation."
(interactive)
(lyskom-change-pres-or-motd-2
(let ((no (lyskom-read-conf-no (lyskom-get-string 'who-to-put-motd-for)
'all t nil t)))
'(all) t nil t)))
(if (zerop no)
(setq no lyskom-pers-no))
(blocking-do 'get-conf-stat no))
......@@ -990,7 +991,7 @@ TYPE is either 'pres or 'motd, depending on what should be changed."
(interactive)
(let ((conf-stat (or (lyskom-read-conf-stat
(lyskom-get-string 'who-to-remove-motd-for)
'all 'empty)
'(all) t)
(blocking-do 'get-conf-stat lyskom-pers-no))))
(cond
((null conf-stat)
......@@ -1019,7 +1020,7 @@ back on lyskom-to-do-list."
(blocking-do 'get-conf-stat conf-no)
(lyskom-read-conf-stat
(lyskom-get-string 'go-to-conf-p)
'all ""))))
'(all) nil "" t))))
(lyskom-go-to-conf conf)))
......@@ -1224,7 +1225,7 @@ If you are not member in the conference it will be flagged with an asterisk."
(interactive)
(let ((conf-stat (lyskom-read-conf-stat
(lyskom-get-string 'name-to-be-changed)
'all)))
'(all))))
(if (null conf-stat)
(lyskom-insert-string 'no-such-conf-or-pers)
(let (name)
......@@ -1254,13 +1255,13 @@ If you are not member in the conference it will be flagged with an asterisk."
(interactive)
(let ((supervisee (lyskom-read-conf-stat
(lyskom-get-string 'who-to-change-supervisor-for)
'all)))
'(all))))
(if (null supervisee)
(lyskom-insert-string 'no-such-conf-or-pers)
(lyskom-tell-internat 'kom-tell-change-supervisor)
(let ((supervisor (lyskom-read-conf-stat
(lyskom-get-string 'new-supervisor)
'all)))
'(all))))
(lyskom-format-insert 'change-supervisor-from-to
supervisee
supervisor)
......@@ -1385,7 +1386,7 @@ If MARK-NO == 0, review all marked texts."
"Change the password for a person."
(interactive)
(let ((pers-no (lyskom-read-conf-no (lyskom-get-string 'whos-passwd)
'pers 'empty "" t))
'(pers) t "" t))
(old-pw (silent-read (lyskom-get-string 'old-passwd)))
(new-pw1 (silent-read (lyskom-get-string 'new-passwd)))
(new-pw2 (silent-read (lyskom-get-string 'new-passwd-again))))
......@@ -1789,7 +1790,7 @@ the user has used a prefix command argument."
((eq action 'add-copy) 'who-to-add-copy-q)
((eq action 'sub) 'who-to-sub-q)
(t (lyskom-error "internal error"))))
'all
'(all)
nil
(if conf (conf-stat->name conf) "")))
(result nil))
......
......@@ -119,7 +119,7 @@ otherwise: the conference is read with lyskom-completing-read."
(let ((conf-no
(or conf-no
(lyskom-read-conf-no (lyskom-get-string 'conf-for-status)
'all nil nil t)))
'(all) nil nil t)))
conf-stat)
(cache-del-conf-stat conf-no)
(setq conf-stat (blocking-do 'get-conf-stat conf-no))
......@@ -266,7 +266,7 @@ otherwise: the conference is read with lyskom-completing-read."
(let ((pers-no
(or pers-no
(lyskom-read-conf-no (lyskom-get-string 'pers-for-status)
'pers "" nil t)))
'(pers) nil "" t)))
conf-stat
pers-stat)
(cache-del-conf-stat pers-no)
......@@ -422,7 +422,7 @@ otherwise: the conference is read with lyskom-completing-read."
(lyskom-read-conf-no
(format (lyskom-get-string 'who-to-send-message-to)
(lyskom-get-string 'everybody))
'all t
'(all) t
;; Initial string:
(cond
((eq kom-default-message-recipient 'everybody) nil)
......@@ -961,7 +961,7 @@ Format is 23:29 if the text is written today. Otherwise 04-01."
(interactive)
(let ((conf-stat (lyskom-read-conf-stat
(lyskom-get-string 'conf-to-set-garb-nice-q)
'all)))
'(all))))
(if (not conf-stat)
(lyskom-insert-string 'somebody-deleted-that-conf)
(let ((garb-nice (lyskom-read-number
......@@ -987,15 +987,15 @@ Format is 23:29 if the text is written today. Otherwise 04-01."
(interactive)
(let ((conf-stat (lyskom-read-conf-stat
(lyskom-get-string 'conf-to-set-permitted-submitters-q)
'all)))
'(all))))
(if (not conf-stat)
(lyskom-insert-string 'somebody-deleted-that-conf)
(let ((new-conf (lyskom-read-conf-stat
(lyskom-format 'new-permitted-submitters-q
(conf-stat->name conf-stat))
'all
'empty)))
'(all)
t)))
(if (eq new-conf nil)
(lyskom-format-insert 'permitted-submitters-removed-for-conf
conf-stat)
......@@ -1023,13 +1023,13 @@ Format is 23:29 if the text is written today. Otherwise 04-01."
(interactive)
(let ((conf-stat (lyskom-read-conf-stat
(lyskom-get-string 'conf-to-set-super-conf-q)
'all)))
'(all))))
(if (not conf-stat)
(lyskom-insert-string 'somebody-deleted-that-conf)
(let ((new-conf (lyskom-read-conf-stat
(lyskom-format 'new-super-conf-q
(conf-stat->name conf-stat))
'all)))
'(all))))
;; Set the super conference for conf-stat to new-conf.
(lyskom-format-insert 'super-conf-for-is
......@@ -1378,7 +1378,7 @@ membership info."
(interactive)
(let* ((conf-no (lyskom-read-conf-no
(lyskom-get-string 'what-conf-to-change)
'confs nil "" t))
'(conf) nil "" t))
(open (j-or-n-p (lyskom-get-string 'anyone-member)))
(secret (if (not open)
(j-or-n-p (lyskom-get-string 'secret-conf))))
......
......@@ -26,29 +26,25 @@
;;;; ================================================================
;;;;
;;;; File: completing-read.el
;;;; Author: David Byers
;;;;
;;;; This file implements functions for reading a conference name
;;;; or a person name with completion and other help.
;;;;
;; Overview of `exported' functions from this file:
;; lyskom-read-conf-no returns conf-no
;; lyskom-read-conf-stat returns conf-stat
;; lyskom-read-conf-name returns name
(setq lyskom-clientversion-long
(concat
lyskom-clientversion-long
"$Id$\n"))
;;; Author: Linus Tolke
(defvar lyskom-name-hist nil)
;;; Completing-function
(defvar lyskom-name-hist nil)
;;; ============================================================
;;;
;;; Name lookup caches
;;;
(defvar lyskom-completing-who-info-cache nil
"Temporary cache of who-info data")
......@@ -82,6 +78,11 @@ but first checks a cache."
lyskom-completing-lookup-name-cache))
tmp))))
;;; ============================================================
;;;
;;; Keymaps
;;;
(defvar lyskom-minibuffer-local-completion-map
(let ((map (copy-keymap minibuffer-local-completion-map)))
......@@ -96,356 +97,637 @@ but first checks a cache."
"Keymap used for reading LysKOM names.")
(defun lyskom-read-conf-no (prompt type &optional empty initial mustmatch)
"Returns the conf-no of a conf or person read by lyskom-read-conf-name.
The question is prompted with PROMPT.
Only the conferences of TYPE are allowed.
The TYPE allows for subsets of the entire Lyskom-name space:
* all
* confs only conferences
* pers only persons
* logins only persons that are logged in right now.
* conflogin conferences and persons that are logged in.
If EMPTY is non-nil then the empty string is allowed (returns 0).
INITIAL is the initial contents of the input field."
(lyskom-completing-clear-cache)
(let (read)
(while (and
(string=
(setq read
(lyskom-read-conf-name prompt type mustmatch initial))
"")
(not empty)))
(if (string= read "")
0
(lyskom-read-conf-name-internal read type 'conf-no))))
(defun lyskom-read-conf-stat (prompt type &optional empty initial)
"Exactly the same as lyskom-read-conf-no but returns the conf-stat if possible.
Arguments: PROMPT TYPE EMPTY INITIAL
The TYPE allows for subsets of the entire Lyskom-name space:
* all
* confs only conferences
* pers only persons
* logins only persons that are logged in right now.
If EMPTY is non-nil then the empty string is allowed (returns nil)."
(lyskom-completing-clear-cache)
(let ((no (lyskom-read-conf-no prompt type empty initial t)))
(if (or (null no) (zerop no))
nil
(blocking-do 'get-conf-stat no))))
(defun lyskom-read-conf-name (prompt type
&optional mustmatch
initial)
"Read a LysKOM name, prompting with PROMPT.
The TYPE allows for subsets of the entire Lyskom-name space:
* all
* confs only conferences
* pers only persons
* logins only persons that are logged in right now.
The third argument MUSTMATCH makes the function always return the conf-no and
never the read string.
The fourth argument INITIAL is the initial contents of the input-buffer.
"Read a conference name from the minibuffer with completion and
return its number or zero if nothing was matched.
See lyskom-read-conf for a description of the parameters."
(let ((conf-stat (lyskom-read-conf prompt type empty initial mustmatch)))
(cond ((null conf-stat) 0)
((stringp conf-stat) 0)
(t (conf-stat->conf-no conf-stat)))))
(defun lyskom-read-conf-stat (prompt type &optional empty initial mustmatch)
"Read a conference name from the minibuffer with completion and
return its conf-stat or nil if nothing was matched.
See lyskom-read-conf for a description of the parameters."
(let ((conf-stat (lyskom-read-conf prompt type empty initial mustmatch)))
(cond ((null conf-stat) nil)
((stringp conf-stat) nil)
(t conf-stat))))
(defun lyskom-read-conf-name (prompt type &optional empty initial mustmatch)
"Read a conference name from the minibuffer with completion and
return its name.
See lyskom-read-conf for a description of the parameters."
(let ((conf-stat (lyskom-read-conf prompt type empty initial mustmatch)))
(cond ((null conf-stat) "")
((stringp conf-stat) conf-stat)
(t (conf-stat->name conf-stat)))))
(defun lyskom-read-conf (prompt type &optional empty initial mustmatch)
"Completing read a conference or person from the minibuffer.
PROMPT is the prompt type type.
TYPE is the type of conferences to return. It is a list of one or
more of the following:
all Return any conference,
conf Return conferences (not letterboxes),
pers Return persons (letterboxes),
login Return persons who are also logged-in, and
none Return names that do not match anything in the database.
Optional arguments
EMPTY allow nothing to be entered.
INITIAL initial contents of the minibuffer
MUSTMATCH if non-nil, the user must enter a valid name.
The return value may be one of
A conf-stat: The conf-stat associated with the name entered,
nil: Nothing was entered, or
A string: A name that matched nothing in the database."
Returns the name."
(lyskom-completing-clear-cache)
(let* ((completion-ignore-case t)
;; When lyskom-read-conf-name-internal is called the current-buffer
;; is the minibuffer and the buffer-local variable lyskom-proc is not
;; correct. Then the variable lyskom-blocking-process must be set
;; instead. It is not buffer-local but scopes the let.
(lyskom-blocking-process lyskom-proc)
(minibuffer-local-completion-map
lyskom-minibuffer-local-completion-map)
(minibuffer-local-must-match-map
lyskom-minibuffer-local-must-match-map))
(completing-read prompt
'lyskom-read-conf-name-internal
type
mustmatch
initial
'lyskom-name-hist)))
lyskom-minibuffer-local-must-match-map)
(read-string nil)
(result nil)
(keep-going t))
(while keep-going
(setq read-string (completing-read prompt
'lyskom-read-conf-internal
type
mustmatch
initial
'lyskom-name-hist))
(setq result
(cond ((null read-string) nil)
((string= "" read-string) nil)
(t (lyskom-lookup-conf-by-name read-string type))))
(setq keep-going (and (not empty)
(null result))))
result))
(defun lyskom-read-conf-name-internal-verify-type (cs predicate logins)
"Returns true if CONF-STAT is of the correct type.
For types se documentation of lyskom-read-conf-name-internal.
Logins is a list of conf-nos (only significant when PREDICATE is logins)."
(or (eq predicate 'all)
(and (eq predicate 'confs)
(not (conf-type->letterbox
(conf-stat->conf-type cs))))
(and (eq predicate 'pers)
(conf-type->letterbox
(conf-stat->conf-type cs)))
(and (eq predicate 'logins)
(memq (conf-stat->conf-no cs) logins))
(and (eq predicate 'conflogin)
(or (not (conf-type->letterbox
(conf-stat->conf-type cs)))
(memq (conf-stat->conf-no cs) logins)))
(and (eq predicate 'persnone)
(or (null cs)
(conf-type->letterbox (conf-stat->conf-type cs))))))
(defun lyskom-read-conf-name-internal (string predicate all)
"The \"try-completion\" for the lyskom-read name.
STRING is the string to be matched.
PREDICATE is one of:
* all
* confs only conferences
* pers only persons
* logins only persons that are logged in right now.
* conflogin union of confs and logins
* persnone only existing persons and strings that are not prefixes of existing persons.
If third argument ALL is t then we are called from all-completions.
If third argument ALL is nil then we are called from try-completion.
If third argument ALL is 'conf-no then we are called from lyskom name
to conf-no translator."
(let* ((alllogins (and (string= string "")
(or (eq predicate 'logins)
(eq predicate 'conflogin))))
(list (if (or (not alllogins)
(eq predicate 'conflogin))
(lyskom-completing-lookup-name string)))
(nos (listify-vector (conf-list->conf-nos list)))
(parlist (if (memq predicate '(pers confs conflogin persnone))
(let ((nos nos)
(typs (listify-vector
(conf-list->conf-types list)))
res)
(while nos
(setq res (cons (cons (car nos) (car typs)) res))
(setq nos (cdr nos)
typs (cdr typs)))
res)))
(logins (and (or (eq predicate 'logins)
(eq predicate 'conflogin))
(mapcar
(function (lambda (ele)
(who-info->pers-no ele)))
(lyskom-completing-who-is-on))))
(mappedlist (cond
(alllogins logins)
((eq predicate 'all) nos)
((eq predicate 'confs)
(apply 'append
(mapcar (function