Commit 3648ed36 authored by David Byers's avatar David Byers
Browse files

Bugfixar, bättre completion, säkrare hantering av C-g i vissa funktioner, target check i makefilen

parent f323ad61
Tue Aug 27 08:49:11 1996 David Byers <davby@sen2.ida.liu.se>
* commands1.el (kom-quit): Fnga C-g.
* swedish-strings.el, english-strings.el (lyskom-strings): Lade
till person-not-logged-in-r och no-such-session-r
* macros.el: Lade till kommentarer.
* edit-text.el (lyskom-edit-send-check-recipients): Flytta
markren till inlggshuvudet medan man frgar om mottagarna r
relevanta.
* clienttypes.el (collector-push): Ny funktion.
(set-value-of-collector): Ny funktion.
(set-collector->value): Ny funktion.
(collector->value): Ny funktion.
(make-collector): Ny funktion.
* review.el (lyskom-get-texts-by): Anvnd collectors istf skumma
kombinationer av initiate och cache-funktioner.
* prioritize.el: Anvnd lyskom-wait-queue hr.
(lyskom-prioritize-handle-get-conf-stat): Anvnd
collector-strukturen istf en global variabel.
* edit-text.el (lyskom-edit-send-check-recipients): Fixade bugen
som gjorde att man slapp skriva texter som var kommentarer till
mnga texter. (lyskom-edit-send-check-recipients): Anvnd
collector-strukturen istf dynamiska variabler.
Tue Aug 27 00:51:35 1996 David Kgedal <kg@infovav.se>
* startup.el (lyskom): Anvnd prefix-argumentet som startvrde p
lyskom-session-priority.
Mon Aug 26 13:04:07 1996 David Byers <davby@sen2.ida.liu.se>
* completing-read.el (lyskom-session-from-conf): Ny funktion.
(lyskom-read-session-no): Omskriven att anvnda lyskom-read-conf.
(lyskom-read-conf-internal): Hantera sessionsnummer.
* vars.el.in (kom-permissive-completion): Ny variabel.
(lyskom-elisp-variables): Lade till kom-permissive-completion.
* commands2.el (kom-send-message): Anvnd
kom-permissive-completion fr att styra lyskom-read-conf-no.
* commands1.el (kom-status-session): Hantera prefixargument.
* completing-read.el (lyskom-complete-string-next-char): Stt
buffert s lyskom-unicase-char skert fungerar.
Sat Aug 24 23:54:55 1996 Per Cederqvist <ceder@lysator.liu.se>
* flags.el (lyskom-read-options-eval): Use equal instead of = so
......
......@@ -90,6 +90,10 @@ lyskom.el: $(HEADER-EL) $(SWEDISH-EL) $(PARTS-EL)
lyskom.elc: lyskom.el
$(EMACS-BATCH) -f batch-byte-compile lyskom.el
.PHONY: check
check:
$(EMACS-BATCH) -l check-strings.el -f lyskom-check-strings
# Do "make verbose" to see where things go wrong
.PHONY: verbose
verbose: verbose-el lyskom.elc
......
......@@ -566,3 +566,62 @@ The element last pushed is first in the list."
(aset (cdr arg) 6 string))
;;; ================================================================
;;; ======================================================================
;;;
;;; collector
;;;
;;; A collector is used when a handler needs to pass information
;;; back to a function using asynchronous calls. You could use
;;; dynamically scoped variables, but that causes problems when
;;; the user quits before all handlers have been called since the
;;; result variable will be out of scope for the remaining handlers.
;;; The best-case scenario will be a crash. The worst-case scenario
;;; is when the handler clobbers another variable with the same name
;;; that has come into scope.
;;;
;;; So, so collect a number of results, do the following:
;;;
;;; (setq <result> (make-collector))
;;; (<loop-function>
;;; (initiate-<någonting> '<queue> <function> <argl> <result>))
;;; (lyskom-wait-queue '<queue>)
;;; (<use> (collector->value <result>))
;;;
;;; where function is something like this:
;;;
;;; (defun <funktion> (data-från-servern collector)
;;; (set-collector->value collector
;;; (cons (<behandla> data-från-servern)
;;; (collector->value collector))))
;;;
;;; or shorter,
;;;
;;; (defun <funktion> (data-från-servern collector)
;;; (collector-push (<behandla> data-från-servern)))
;;;
;;; This sidestepping protects the handler from scope changes.
;;;
(defun make-collector ()
"Create a data type for collecting asynchronous results safely"
(cons 'COLLECTOR nil))
(defsubst collector->value (collector)
"Get the current value of a collector"
(cdr collector))
(defsubst set-collector->value (collector value)
"Set the calue of a collector"
(setcdr collector value))
(defun set-value-of-collector (value collector)
"For use with lyskom handlers. In other cases, use set-collector->value"
(set-collector->value collector value))
(defun collector-push (value collector)
"Push VALUE onto the front of COLLECTOR's value"
(setcdr collector (cons value (cdr collector))))
......@@ -879,15 +879,19 @@ that text instead."
If optional argument is non-nil then dont ask for confirmation."
(interactive "P")
(lyskom-start-of-command 'kom-quit t)
(cond
((and (lyskom-count-down-edits)
(display-buffer (car lyskom-list-of-edit-buffers))
(not (lyskom-ja-or-nej-p
(lyskom-get-string 'quit-in-spite-of-unsent))))
(lyskom-end-of-command))
((or arg (lyskom-ja-or-nej-p (lyskom-get-string 'really-quit)))
(lyskom-quit))
(t (lyskom-end-of-command))))
(let ((do-end-of-command t))
(unwind-protect
(setq do-end-of-command
(cond
((and (lyskom-count-down-edits)
(display-buffer (car lyskom-list-of-edit-buffers))
(not (lyskom-ja-or-nej-p
(lyskom-get-string 'quit-in-spite-of-unsent))))
t)
((or arg (lyskom-ja-or-nej-p (lyskom-get-string 'really-quit)))
(lyskom-quit) nil)
(t t)))
(if do-end-of-command (lyskom-end-of-command)))))
(defun lyskom-quit ()
......@@ -1818,21 +1822,32 @@ Uses Protocol A version 9 calls"
"Show status for all sessions a person has. Asks for person name.
Optional argument ARG should be a list of sessions to get information
about or a single session number."
(interactive)
(interactive "P")
(let ((sessions (or (cond ((listp arg) arg)
((numberp arg) (list arg)))
(lyskom-read-session-no
(lyskom-get-string 'status-for-session))))
who-info)
(if lyskom-dynamic-session-info-flag
(progn
(setq who-info (listify-vector
(blocking-do 'who-is-on-dynamic t t 0)))
(mapcar (function (lambda (x) (lyskom-status-session-9 x who-info)))
sessions))
(setq who-info (listify-vector (blocking-do 'who-is-on)))
(mapcar (function (lambda (x) (lyskom-status-session-8 x who-info)))
sessions))))
(cond ((null sessions)
(lyskom-insert-string 'no-such-session-r))
((and (numberp (car sessions))
(<= (car sessions) 0))
(lyskom-format-insert
(lyskom-get-string 'person-not-logged-in-r)
(- (car sessions))))
(t
(if lyskom-dynamic-session-info-flag
(progn
(setq who-info (listify-vector
(blocking-do 'who-is-on-dynamic t t 0)))
(mapcar (function
(lambda (x) (lyskom-status-session-9 x
who-info)))
sessions))
(setq who-info (listify-vector (blocking-do 'who-is-on)))
(mapcar (function
(lambda (x) (lyskom-status-session-8 x who-info)))
sessions))))))
(defun lyskom-status-session-8 (sid who-info-list)
......
......@@ -422,8 +422,11 @@ 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
(if kom-permissive-completion
'(all)
'(login conf))
;; Initial string:
t
(cond
((eq kom-default-message-recipient 'everybody) nil)
......@@ -440,7 +443,7 @@ otherwise: the conference is read with lyskom-completing-read."
(t
(if lyskom-last-personal-message-sender
(cons lyskom-last-personal-message-sender 0)
""))) t))))
"")))))))
(if (zerop target)
(lyskom-insert (lyskom-get-string 'message-all-info))
(lyskom-format-insert 'message-recipient-info target))
......
......@@ -198,7 +198,11 @@ persons who are logged on."
(lyskom-completing-who-is-on)))
(defun lyskom-read-conf-expand-specials (string predicate login-list x-list)
(defun lyskom-read-conf-expand-specials (string
predicate
login-list
x-list
&optional return-cs)
"Used internally by lyskom-read-conf-internal to expand person and
conference number specifications to something useful."
(cond ((string-match (lyskom-get-string 'person-or-conf-no-regexp) string)
......@@ -211,24 +215,34 @@ conference number specifications to something useful."
predicate
login-list
x-list))
(list string))))))
(if return-cs
cs
(list string)))))
((string-match (lyskom-get-string 'session-no-regexp) string)
(let* ((no (string-to-int (match-string 1 string)))
(si (blocking-do 'get-session-info no))
(cs (and si
(blocking-do 'get-conf-stat
(session-info->pers-no si)))))
(if (and cs
(lyskom-read-conf-internal-verify-type
(conf-stat->conf-no cs)
(conf-stat->conf-type cs)
predicate
login-list
x-list))
(if return-cs
cs
(list string)))))))
(defun lyskom-read-conf-lookup-specials (string predicate login-list x-list)
"Used internally by lyskom-read-conf-internal to look up conf-stats
from person and conference number specifications."
(if (string-match (lyskom-get-string 'person-or-conf-no-regexp)
string)
(progn
(let* ((no (string-to-int (match-string 1 string)))
(cs (blocking-do 'get-conf-stat no)))
(if (and cs
(lyskom-read-conf-internal-verify-type
(conf-stat->conf-no cs)
(conf-stat->conf-type cs)
predicate
login-list
x-list))
cs)))))
(lyskom-read-conf-expand-specials string
predicate
login-list
x-list
t))
(defun lyskom-lookup-conf-by-name (string predicate)
"Return the conf-z-info associated with STRING that also satisfies
......@@ -327,6 +341,8 @@ function work as a name-to-conf-stat translator."
candidate-list))
((string-match (lyskom-get-string 'person-or-conf-no-regexp)
string) nil)
((string-match (lyskom-get-string 'session-no-regexp)
string) nil)
((lyskom-read-conf-internal-verify-type nil
nil
predicate
......@@ -351,6 +367,8 @@ function work as a name-to-conf-stat translator."
(specials nil)
((string-match (lyskom-get-string 'person-or-conf-no-regexp)
string) nil)
((string-match (lyskom-get-string 'session-no-regexp)
string) nil)
(t (lyskom-read-conf-internal-verify-type nil
nil
predicate
......@@ -377,6 +395,8 @@ function work as a name-to-conf-stat translator."
(names names)
((string-match (lyskom-get-string 'person-or-conf-no-regexp)
string) nil)
((string-match (lyskom-get-string 'session-no-regexp)
string) nil)
((lyskom-read-conf-internal-verify-type nil
nil
predicate
......@@ -397,9 +417,11 @@ function work as a name-to-conf-stat translator."
predicate
login-list
candidate-list)))
(cond (specials specials)
(cond (specials (car specials))
((string-match (lyskom-get-string 'person-or-conf-no-regexp)
string) nil)
((string-match (lyskom-get-string 'session-no-regexp)
string) nil)
((lyskom-read-conf-internal-verify-type nil
nil
predicate
......@@ -428,6 +450,8 @@ function work as a name-to-conf-stat translator."
((= (length name-list) 1) (car name-list))
((string-match (lyskom-get-string 'person-or-conf-no-regexp)
string) nil)
((string-match (lyskom-get-string 'session-no-regexp)
string) nil)
(t (or (lyskom-completing-cache-completion
(lyskom-complete-string name-list)
x-list)
......@@ -759,28 +783,31 @@ the LysKOM rules of string matching."
(char nil)
(xchar nil))
(mapcar
(function
(lambda (x)
(cond ((>= (aref x 0) (aref x 1))
(setq eofp t)
(setq matchp nil))
((eq (aref (aref x 2) (aref x 0)) ?\()
(setq open-paren-p t))
((eq (aref (aref x 2) (aref x 0)) ?\))
(setq close-paren-p t))
((eq (aref (aref x 2) (aref x 0)) ?\ )
(setq spacep t)))
(setq matchp (and matchp
(if (null char)
(progn
(setq xchar (aref (aref x 2)
(aref x 0)))
(setq char (lyskom-unicase-char xchar)))
(eq char (lyskom-unicase-char (aref (aref x 2)
(aref x 0)))))))))
data-list)
(lyskom-save-excursion
(set-buffer (process-buffer lyskom-blocking-process))
(mapcar
(function
(lambda (x)
(cond ((>= (aref x 0) (aref x 1))
(setq eofp t)
(setq matchp nil))
((eq (aref (aref x 2) (aref x 0)) ?\()
(setq open-paren-p t))
((eq (aref (aref x 2) (aref x 0)) ?\))
(setq close-paren-p t))
((eq (aref (aref x 2) (aref x 0)) ?\ )
(setq spacep t)))
(setq matchp (and matchp
(if (null char)
(progn
(setq xchar (aref (aref x 2)
(aref x 0)))
(setq char (lyskom-unicase-char xchar)))
(eq char (lyskom-unicase-char
(aref (aref x 2)
(aref x 0)))))))))
data-list))
(aset state 1 xchar)
(cond (eofp (aset state 0 'eof))
......@@ -814,30 +841,31 @@ the LysKOM rules of string matching."
(defun lyskom-read-session-no (prompt &optional empty initial only-one)
"Returns a list of session numbers of a session by reading either
the number of the session or a name.
The question is prompted with PROMPT.
If EMPTY is non-nil then the empty string is allowed (returns 0).
INITIAL is the initial contents of the input field.
If ONLY-ONE is non-nil only one session number will be returned."
(lyskom-completing-clear-cache)
(let (result data done
(lyskom-blocking-process lyskom-proc))
(while (not done)
(setq data (lyskom-read-session-no-aux prompt t initial))
(cond ((and (string= data "") (not empty)))
((string= data "") (setq done t result nil))
(t (setq result
(lyskom-read-session-internal data '(login)
'lyskom-lookup)
done t))))
(if (and only-one (> (length result) 1))
(setq result
(lyskom-read-session-resolve-ambiguity result)))
result))
(let ((possible-matches
(lyskom-session-from-conf
(lyskom-read-conf-no prompt
(if kom-permissive-completion
'(pers)
'(login))
empty
initial
t))))
(if (and (> (length possible-matches) 1)
only-one)
(lyskom-read-session-resolve-ambiguity possible-matches)
possible-matches)))
(defun lyskom-session-from-conf (conf-no)
(let ((who-list (lyskom-completing-who-is-on))
(sessions nil))
(while who-list
(if (eq (who-info->pers-no (car who-list)) conf-no)
(setq sessions (cons (who-info->connection (car who-list))
sessions)))
(setq who-list (cdr who-list)))
(cond ((and (null sessions) kom-permissive-completion) (list (- conf-no)))
(t sessions))))
(defun lyskom-read-session-resolve-ambiguity (sessions)
......@@ -902,74 +930,6 @@ If ONLY-ONE is non-nil only one session number will be returned."
(car (car who-info))
nil))))
(list (session-info->connection (cdr (assoc result who-info)))))))
(defun lyskom-read-session-no-aux (prompt
&optional mustmatch
initial)
"Read a LysKOM name or session number, prompting with PROMPT.
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.
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-session-internal
'(login)
mustmatch
initial
'lyskom-name-hist)))
(defun lyskom-read-session-internal (string predicate all)
(let* ((result nil)
(partial (lyskom-read-conf-internal string predicate all))
(who-list (if (or (null partial)
(eq all 'lyskom-lookup))
(mapcar (function
(lambda (el)
(cons
(number-to-string (who-info->connection el))
el)))
(lyskom-completing-who-is-on))))
(result (cond
((and (null who-list)
(not (eq 'lyskom-lookup all))) nil)
((eq all nil) ; try-completion
(try-completion string who-list nil))
((eq all t) ; all-completions
(all-completions string who-list nil))
((eq all 'lambda) ; exact match
(and (assoc string who-list) t))
((eq all 'lyskom-lookup) ; get number
(car-safe (assoc string who-list))))))
(cond ((eq all 'lyskom-lookup)
(if partial
(let* ((output nil)
(list who-list)
(num (string-to-number string))
(conf-no
(if (= 0 num) ; Dont lookup unless necessary
(conf-z-info->conf-no partial))))
(while list
(if (or (eq conf-no (who-info->pers-no (cdr (car list))))
(eq num (who-info->connection (cdr (car list)))))
(setq output (cons
(who-info->connection (cdr (car list)))
output)))
(setq list (cdr list)))
output)
(list (string-to-number result))))
(t (or partial result)))))
......@@ -424,9 +424,9 @@ Entry to this mode runs lyskom-edit-mode-hook."
(lyskom-abort-edit
(apply 'lyskom-message (cdr-safe err)))
(lyskom-no-subject
(lyskom-beep lyskom-ding-on-no-subject)
(if (cdr-safe (cdr-safe err))
(goto-char (car-safe (cdr-safe (cdr-safe err)))))
(lyskom-beep lyskom-ding-on-no-subject)
(lyskom-message "%s" (lyskom-get-string (car (cdr err))))
(condition-case arg
(let ((text ""))
......@@ -449,6 +449,7 @@ text is a member of some recipient of this text."
(recipient-list nil)
(author-list nil)
(author-is-member nil)
(collector (make-collector))
(extra-headers nil)
(me (save-excursion (set-buffer (process-buffer lyskom-proc))
lyskom-pers-no))
......@@ -474,10 +475,15 @@ text is a member of some recipient of this text."
(if (and kom-confirm-multiple-recipients
(not (eq kom-confirm-multiple-recipients 'before))
(> (- (length recipient-list) num-me) 1))
(if (not (lyskom-j-or-n-p (lyskom-format 'comment-all-relevant-p) t))
(signal 'lyskom-edit-text-abort (list "%s"
(lyskom-get-string
'please-edit-recipients)))))
(save-excursion
(goto-char (point-min))
(if (not
(lyskom-j-or-n-p
(lyskom-format 'comment-all-relevant-p) t))
(signal 'lyskom-edit-text-abort
(list "%s"
(lyskom-get-string
'please-edit-recipients))))))
(if (and kom-check-commented-author-membership
(assq 'comm-to (cdr misc-list)))
......@@ -529,15 +535,13 @@ text is a member of some recipient of this text."
nil
author-number conference-number)))
recipient-list)
(lyskom-list-use 'sending
(function
(lambda (x)
(if (boundp author-is-member)
(setq author-is-member
(memq
nil
(mapcar 'not x)))))))
'collector-push
collector)
(lyskom-wait-queue 'sending)
(setq author-is-member (collector->value collector))
(if (and (null author-is-member)
(not (zerop author-number))
(lyskom-j-or-n-p
......
......@@ -383,7 +383,7 @@ Read all about it at http://www.lysator.liu.se/history/")
(who-is-active-all . "Showing all sessions.\n")
(who-is-active-last-minutes . "Showing all sessions active tha last %#1d minutes.\n")
(showing-invisibles . "Showing invisible sessions.\n")
(null-who-info . "No one (active) is logged in.\n")
(null-who-info . "No one (active) is logged on.\n")
; From commands2.el:
......@@ -713,6 +713,7 @@ Group message to %#3M\nfrom %#2P (%#4s):
; From completing-read.el:
(person-or-conf-no-regexp . "\\`[ \t]*[mpMP]\\w*[ \t]+\\([0-9]+\\)\\'")
(session-no-regexp . "\\`[ \t]*[sS]\\w*[ \t]+\\([0-9]+\\)\\'")
; From prioritize.el:
......@@ -938,6 +939,9 @@ Text:
(who-i-am-client . "The programs is lyskom.el, version %#1s.\n")
(who-i-am-server . "This is %#1s, version %#2s.\n")
(who-i-am-emacs . "Running under %#1s.\n")
(no-such-session-r . "That session does not exist. Perhaps the user is not logged on.\n")
(person-not-logged-in-r . "%#1P is not logged on.\n")
(session-status . "Session %#1d is %#2P <%#2p>
%#5s %#7s %#4M
Using %#6D from %#3s\n")
......
No preview for this file type
......@@ -36,7 +36,15 @@
"$Id$\n"))
;;; ======================================================================
;;; Use lyskom-provide to supply a definition that is only to be used
;;; if no definition already exists. The definition will be evaluated at
;;; both compile and run time.
;;;
;;; lyskom-provide-macros behaves like defmacro
;;; lyskom-provide-function behaves like defun
;;; lyskom-provide-subst behaves like defsubst
;;;
(defmacro lyskom-provide (definer name rest)
(` (progn (eval-when-compile
......@@ -59,7 +67,9 @@
(` (ly