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

New string parser (experimental).

Speedups to kom-list-persons, kom-list-conferences, kom-list-re
New command kom-list-created-conferences.
parent be8e7380
2000-08-10 David Byers <davby@ida.liu.se>
* commands1.el (kom-list-created-conferences): New function.
(lyskom-list-created-conferences-2): New function.
Kill da bottlenecks:
* parse.el (lyskom-parse-raw-string): Get rid of call to
lyskom-string-to-parse.
Improve list names:
* commands1.el (kom-list-conferences): Use lookup-z-name instead
of lookup-name.
(lyskom-list-conf-print): Show passive memberships as "-" in the
result list. Use conf-z-infos instead of conf-nos. Better error
messages.
(kom-list-re): Send conf-z-infos to lyskom-format to speed things
up a bit. Better error messages.
(kom-list-persons): Use lookup-z-name instead of lookup-name.
Better error messages.
(lyskom-list-pers-print): Use conf-z-infos instead of conf-nos to
speed things up a bit.
* lyskom-rest.el (lyskom-format-aux-help): Allow conf-z-info as
argument to lyskom-format letters M, P, m, p.
(lyskom-current-error): New function.
Cleanup of easy TODO items:
* aux-items.el (lyskom-print-creating-software): Print creating
software when current command is kom-review-noconversion.
Fix review many to conferences with few texts:
* review.el (lyskom-get-letters-to): Protect nthcdr from negative
arguments.
......
......@@ -271,11 +271,6 @@ j-or-n-p.
** OSORTERADE
lyskom-get-texts-to är buggig. Om man återser senaste N av vem som
helst till ett möte och det inte finns N texter så buggar den ur.
Den borde klippa till max texter i mötet.
FIX BY: 0.46
ispell-hooken rättar ärendet i bufferten men det blir inte rättat
i den inskickade versionen av inlägget. Kanske.
FIX BY: 0.46
......
......@@ -553,7 +553,8 @@ return non-nil if the item is to be included in the list."
(lyskom-aux-item-terminating-button item obj)))
(defun lyskom-print-creating-software (item &optional obj)
(when kom-show-creating-software
(when (or kom-show-creating-software
(eq lyskom-current-command 'kom-review-noconversion))
(concat
(lyskom-format 'creating-software-aux (aux-item->data item))
(lyskom-aux-item-terminating-button item obj))))
......
......@@ -1380,21 +1380,24 @@ Args: CONF-STAT MEMBERSHIP"
;;; Rewritten: linus
(def-kom-command kom-list-persons (match)
"List all persons whose name matches MATCH (a string)."
(interactive (list (lyskom-read-string
"List all conferences whose name matches MATCH (a string).
Those that you are not a member in will be marked with an asterisk."
(interactive (list (lyskom-read-string
(lyskom-get-string 'search-for-pers))))
(mapcar
(function (lambda (no)
(lyskom-list-pers-print no)))
(lyskom-extract-persons (blocking-do 'lookup-name match))))
(let ((result (blocking-do 'lookup-z-name match 1 0)))
(if result
(if (conf-z-info-list->conf-z-infos result)
(lyskom-traverse info (conf-z-info-list->conf-z-infos result)
(lyskom-list-pers-print info))
(lyskom-format-insert 'no-matching-perss match))
(lyskom-insert (lyskom-current-error)))))
(defun lyskom-list-pers-print (conf-no)
(defun lyskom-list-pers-print (conf-z)
"Print name of the person CONF-NO for kom-list-persons."
(lyskom-format-insert "%[%#1@%4#2:p %#3P%]\n"
(lyskom-default-button 'pers conf-no)
conf-no
conf-no))
(lyskom-format-insert "%[%#1@%4#2:p %#2P%]\n"
(lyskom-default-button 'pers (conf-z-info->conf-no conf-z))
conf-z))
......@@ -1409,21 +1412,76 @@ Args: CONF-STAT MEMBERSHIP"
Those that you are not a member in will be marked with an asterisk."
(interactive (list (lyskom-read-string
(lyskom-get-string 'search-for-conf))))
(mapcar
(function (lambda (no)
(lyskom-list-conf-print no)))
(lyskom-extract-confs (blocking-do 'lookup-name match))))
(let ((result (blocking-do 'lookup-z-name match 0 1)))
(if result
(if (conf-z-info-list->conf-z-infos result)
(lyskom-traverse info (conf-z-info-list->conf-z-infos result)
(lyskom-list-conf-print info))
(lyskom-format-insert 'no-matching-confs match))
(lyskom-insert (lyskom-current-error)))))
(defun lyskom-list-conf-print (conf-no)
(def-kom-command kom-list-created-conferences (arg)
"List all conferences created by some person."
(interactive "P")
(let* ((tmp (blocking-do 'get-uconf-stat lyskom-pers-no))
(pers-no (lyskom-read-conf-no
(if arg 'list-pers-confs-created-by 'list-confs-created-by)
'(pers)
nil
(if (cache-get-uconf-stat lyskom-pers-no)
(cons (conf-stat->name (cache-get-conf-stat lyskom-pers-no)) 0)1
nil)
t)))
(lyskom-message (lyskom-get-string (if arg 'getting-all-pers-confs 'getting-all-confs)))
(let ((result (blocking-do 'lookup-z-name "" (if arg 1 0) 1)))
(lyskom-message (lyskom-get-string (if arg 'getting-all-pers confs-done 'getting-all-confs-done)))
(if result
(if (conf-z-info-list->conf-z-infos result)
(let ((counter (cons 1 (length (conf-z-info-list->conf-z-infos result)))))
(lyskom-traverse conf-z (conf-z-info-list->conf-z-infos result)
(initiate-get-conf-stat 'main
'lyskom-list-created-conferences-2
(conf-z-info->conf-no conf-z)
counter
pers-no
arg
)
)
(lyskom-wait-queue 'main))
(lyskom-insert (lyskom-get-string (if arg 'no-pers-confs-exist 'no-confs-exist))))
(lyskom-format-insert (lyskom-current-error))))))
(defun lyskom-list-created-conferences-2 (cs counter pers-no arg)
(setcar counter (1+ (car counter)))
(lyskom-message (lyskom-format (if arg 'finding-created-pers-confs 'finding-created-confs)
(car counter)
(cdr counter)))
(when (and cs (or (eq (conf-stat->creator cs) pers-no)
(eq (conf-stat->supervisor cs) pers-no)
(eq (conf-stat->super-conf cs) pers-no)))
(lyskom-format-insert "%[%#1@%4#2:m %#3c %4#4s %#2M%]\n"
(lyskom-default-button 'conf (conf-stat->conf-no cs))
cs
(if (lyskom-get-membership (conf-stat->conf-no cs))
?\
(if (lyskom-get-membership (conf-stat->conf-no cs) t)
?- ?*))
(concat (if (eq pers-no (conf-stat->creator cs)) "C" " ")
(if (eq pers-no (conf-stat->supervisor cs)) "O" " ")
(if (eq pers-no (conf-stat->super-conf cs)) "S" " ")))))
(defun lyskom-list-conf-print (conf-z)
"Print a line of info about CONF-NO.
If you are not member in the conference it will be flagged with an asterisk."
(lyskom-format-insert "%[%#1@%4#2:m %#3c %#4M%]\n"
(lyskom-default-button 'conf conf-no)
conf-no
(if (lyskom-get-membership conf-no)
?\ ?*)
conf-no))
(lyskom-format-insert "%[%#1@%4#2:m %#3c %#2M%]\n"
(lyskom-default-button 'conf (conf-z-info->conf-no conf-z))
conf-z
(if (lyskom-get-membership (conf-z-info->conf-no conf-z))
?\
(if (lyskom-get-membership (conf-z-info->conf-no conf-z) t)
?- ?*))))
;;; ================================================================
;;; Lista med regexpar - List regexp
......@@ -1434,18 +1492,20 @@ If you are not member in the conference it will be flagged with an asterisk."
(lyskom-get-string 'search-re))))
(lyskom-format-insert 'matching-regexp regexp)
(let ((conf-list (blocking-do 're-z-lookup regexp 1 1)))
(mapcar
(function (lambda (czi)
(lyskom-format-insert
"%[%#1@%4#2:m %#3c %#4:M%]\n"
(lyskom-default-button
'conf (conf-z-info->conf-no czi))
(conf-z-info->conf-no czi)
(if (conf-type->letterbox
(conf-z-info->conf-type czi))
?P ?M)
(conf-z-info->name czi))))
(conf-z-info-list->conf-z-infos conf-list))))
(if conf-list
(if (conf-z-info-list->conf-z-infos conf-list)
(lyskom-traverse czi (conf-z-info-list->conf-z-infos conf-list)
(lyskom-format-insert
"%[%#1@%4#2:m %#3c %#2:M%]\n"
(lyskom-default-button
'conf (conf-z-info->conf-no czi))
czi
(if (conf-type->letterbox
(conf-z-info->conf-type czi))
?P ?M)
))
(lyskom-format-insert 'no-matching-anys regexp))
(lyskom-format-insert (lyskom-current-error)))))
;;; ================================================================
......
......@@ -326,6 +326,21 @@ and you have finished reading. Please come back later.
(search-for-pers . "Enter search key (RETURN for all users): ")
(search-for-conf . "Enter search key (RETURN for all conferences): ")
(search-re . "Enter search regexp: ")
(no-matching-confs . "No conferences match \"%#1s\".\n")
(no-matching-perss . "No persons match \"%#1s\".\n")
(no-matching-anys . "No persons or conferences match \"%#1s\".\n")
(no-confs-exist . "There are no conferences in the database.\n")
(no-pers-confs-exist . "There are no persons or conferences in the database.\n")
(list-confs-created-by . "List conferences created by: ")
(list-pers-confs-created-by . "List persons and conferences created by: ")
(getting-all-confs . "Retrieving a list of all conferences from the server...")
(getting-all-pers-confs . "Retrieving a list of all persons and conferences from the server...")
(getting-all-confs-done . "Retrieving a list of all conferences from the server...done")
(getting-all-pers-confs-done . "Retrieving a list of all persons and conferences from the server...done")
(finding-created-confs . "Finding created persons and conferences (%#1d av %#2d klart)")
(finding-created-pers-confs . "Finding created persons and conferences (%#1d av %#2d klart)")
(name-to-be-changed . "Name to change: ")
(no-such-conf-or-pers . "The conference or user doesn't exist.\n")
(new-name . "New name: ")
......@@ -1499,6 +1514,7 @@ You must become an active member of the conference to enter it.\n")
(kom-go-to-conf . "Go (to) conference")
(kom-go-to-next-conf . "(Go to) next conference")
(kom-jump . "Skip (all) comments")
(kom-list-created-conferences . "List created conferences")
(kom-list-conferences . "List conferences")
(kom-list-persons . "List users")
(kom-list-news . "List news")
......
......@@ -141,6 +141,10 @@
lyskom-errno))
answer)
(defun lyskom-current-error ()
"Return a string describing the current error"
(lyskom-format 'error-code (lyskom-get-error-text lyskom-errno) lyskom-errno))
;;; ----------------------------------------------------------------
;;; Author: Aronsson
......@@ -1397,6 +1401,11 @@ Note that it is not allowed to use deferred insertions in the text."
(conf-stat->name arg)))
(conf-stat->name arg)))
;; Argument is a conf-z-info
((lyskom-conf-z-info-p arg)
(conf-z-info->name arg))
;; We have an uconf-stat
((lyskom-uconf-stat-p arg)
(uconf-stat->name arg))
......@@ -1424,6 +1433,8 @@ Note that it is not allowed to use deferred insertions in the text."
(setq result
(cond ((integerp arg)
(int-to-string arg))
((lyskom-conf-z-info-p arg)
(int-to-string (conf-z-info->conf-no arg)))
((lyskom-conf-stat-p arg)
(int-to-string (conf-stat->conf-no arg)))
((lyskom-uconf-stat-p arg)
......
......@@ -147,30 +147,63 @@ Signal lyskom-protocol-error if the next token is not a string."
(lyskom-parse-nonwhite-char)
(setq lyskom-parse-pos (1- lyskom-parse-pos))
;; End kludge.
(let ((to-parse (lyskom-string-to-parse)))
(cond
((string-match "\\`[0-9]*\\(\\|H\\)\\'" to-parse)
(signal 'lyskom-parse-incomplete nil))
((null (string-match "\\`[0-9]+H" to-parse))
(lyskom-protocol-error 'lyskom-parse-string
"Expected hollerith, got %S"
to-parse)) ;Not a legal string.
(t
(let ((end (match-end 0))
(len (string-to-int to-parse)))
(setq lyskom-parse-pos (+ lyskom-parse-pos end))
(cond
((< (point-max) (+ lyskom-parse-pos len))
(lyskom-setq-default lyskom-string-bytes-missing
(- (+ lyskom-parse-pos len)
(point-max)))
(signal 'lyskom-parse-incomplete nil))
(t
(prog1 (buffer-substring lyskom-parse-pos
(+ lyskom-parse-pos len))
(lyskom-setq-default lyskom-string-bytes-missing 0)
(setq lyskom-parse-pos (+ lyskom-parse-pos len))))))))))
(goto-char lyskom-parse-pos)
(cond
((looking-at "[0-9]*\\(\\|H\\)\\'")
(signal 'lyskom-parse-incomplete nil))
((null (looking-at "[0-9]+H"))
(lyskom-protocol-error 'lyskom-parse-string
"Expected hollerith, got %S"
(lyskom-string-to-parse))) ;Not a legal string.
(t
(let* ((num (match-string 0))
(end (match-end 0))
(len (string-to-int num)))
(setq lyskom-parse-pos end)
(cond
((< (point-max) (+ lyskom-parse-pos len))
(lyskom-setq-default lyskom-string-bytes-missing
(- (+ lyskom-parse-pos len)
(point-max)))
(signal 'lyskom-parse-incomplete nil))
(t
(prog1 (buffer-substring lyskom-parse-pos
(+ lyskom-parse-pos len))
(lyskom-setq-default lyskom-string-bytes-missing 0)
(setq lyskom-parse-pos (+ lyskom-parse-pos len)))))))))
;;(defun lyskom-parse-raw-string ()
;; "Parse next token as a raw string.
;;Signal lyskom-parse-incomplete if the string is not complete.
;;Signal lyskom-protocol-error if the next token is not a string."
;; ;; Kludge to deal with leading spaces.
;; (lyskom-parse-nonwhite-char)
;; (setq lyskom-parse-pos (1- lyskom-parse-pos))
;; ;; End kludge.
;; (let ((to-parse (lyskom-string-to-parse)))
;; (cond
;; ((string-match "\\`[0-9]*\\(\\|H\\)\\'" to-parse)
;; (signal 'lyskom-parse-incomplete nil))
;; ((null (string-match "\\`[0-9]+H" to-parse))
;; (lyskom-protocol-error 'lyskom-parse-string
;; "Expected hollerith, got %S"
;; to-parse)) ;Not a legal string.
;; (t
;; (let ((end (match-end 0))
;; (len (string-to-int to-parse)))
;; (setq lyskom-parse-pos (+ lyskom-parse-pos end))
;; (cond
;; ((< (point-max) (+ lyskom-parse-pos len))
;; (lyskom-setq-default lyskom-string-bytes-missing
;; (- (+ lyskom-parse-pos len)
;; (point-max)))
;; (signal 'lyskom-parse-incomplete nil))
;; (t
;; (prog1 (buffer-substring lyskom-parse-pos
;; (+ lyskom-parse-pos len))
;; (lyskom-setq-default lyskom-string-bytes-missing 0)
;; (setq lyskom-parse-pos (+ lyskom-parse-pos len))))))))))
(defun lyskom-parse-coding ()
"Parse next token as a raw string.
......
......@@ -308,6 +308,19 @@ du har l
(search-for-pers . "Ange skvillkor (RETURN fr alla personer): ")
(search-for-conf . "Ange skvillkor (RETURN fr alla mten): ")
(search-re . "Ange skuttryck (reguljrt uttryck): ")
(no-matching-confs . "Inga mten uppfyller skvillkoret \"%#1s\".\n")
(no-matching-perss . "Inga personer uppfyller skvillkoret \"%#1s\".\n")
(no-matching-anys . "Inga personer eller mten uppfyller uttrycket \"%#1s\".\n")
(no-confs-exist . "Det finns inga mten i databasen.\n")
(no-pers-confs-exist . "Det finns inga mten eller personer i databasen.\n")
(list-confs-created-by . "Lista mten skapade av: ")
(list-pers-confs-created-by . "Lista mten och personer skapade av: ")
(getting-all-confs . "Hmtar en lista av alla mten frn servern...")
(getting-all-pers-confs . "Hmtar en lista av alla personer och mten frn servern...")
(getting-all-confs-done . "Hmtar en lista av alla mten frn servern...klart")
(getting-all-pers-confs-done . "Hmtar en lista av alla personer och mten frn servern...klart")
(finding-created-confs . "Sker skapade mten (%#1d av %#2d klart)")
(finding-created-pers-confs . "Sker skapade mten och personer (%#1d av %#2d klart)")
(name-to-be-changed . "Ange det namn som skall ndras: ")
(no-such-conf-or-pers . "Mtet eller personen finns ej.\n")
(new-name . "Nytt namn: ")
......@@ -1504,6 +1517,7 @@ Du m
(kom-go-to-conf . "G till mte")
(kom-go-to-next-conf . "G till nsta mte")
(kom-jump . "Hoppa ver alla kommentarer")
(kom-list-created-conferences . "Lista skapade mten")
(kom-list-conferences . "Lista mten")
(kom-list-persons . "Lista personer")
(kom-list-news . "Lista nyheter")
......
......@@ -1223,6 +1223,7 @@ Users are encouraged to use their best sense of humor."
kom-go-to-conf
kom-go-to-next-conf
kom-jump
kom-list-created-conferences
kom-list-conferences
kom-list-persons
kom-list-news
......
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