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

Support saving input in lyskom-read-conf (work on bug 459)

Detailed changes:
> 2003-08-20  David Byers  <byers@lysator.liu.se>
>
> 	Support saving most recent input:
> 	* completing-read.el (lyskom-read-conf-saved-inputs): New
> 	variable.
> 	(lyskom-read-conf-save-input): New function.
> 	(lyskom-read-conf): Call it to save user input.
> 	(lyskom-read-conf-guess-initial): Support arguments to strategy
> 	functions.
> 	(lyskom-default-conference-saved): New function.
>
parent c76671ae
2003-08-20 David Byers <byers@lysator.liu.se>
Support saving most recent input:
* completing-read.el (lyskom-read-conf-saved-inputs): New
variable.
(lyskom-read-conf-save-input): New function.
(lyskom-read-conf): Call it to save user input.
(lyskom-read-conf-guess-initial): Support arguments to strategy
functions.
(lyskom-default-conference-saved): New function.
2003-08-17 David Byers <byers@lysator.liu.se>
Fix bug 1044:
......
......@@ -39,7 +39,7 @@
"$Id$\n"))
(defvar lyskom-name-hist nil)
(defvar lyskom-saved-answers nil)
(defvar lyskom-read-conf-saved-inputs nil)
......@@ -211,6 +211,9 @@ See lyskom-read-conf for a description of the parameters."
(list (text-stat->author
(blocking-do 'get-text-stat (lyskom-get-last-read-text))))))
(defun lyskom-default-conference-saved (sym)
(list (conf-z-info->conf-no (cdr (assq sym lyskom-read-conf-saved-inputs)))))
(defun lyskom-get-initial-conf-strategy (prompt)
(when (listp prompt) (setq prompt (car prompt)))
......@@ -225,7 +228,10 @@ See lyskom-read-conf for a description of the parameters."
(assq 'default default-spec))
(or (assq 'filter prompt-spec)
(assq 'filter cmd-spec)
(assq 'filter default-spec)))))
(assq 'filter default-spec))
(or (assq 'save prompt-spec)
(assq 'save cmd-spec)
(assq 'save default-spec)))))
(defun lyskom-read-conf-guess-initial (prompt predicate)
"Return a guess for the initial value for lyskom-read-conf."
......@@ -234,21 +240,38 @@ See lyskom-read-conf for a description of the parameters."
(filter (cdr (assq 'filter strategy))))
(uconf-stat->name
(car (filter-list (lambda (uconf-stat)
(and uconf-stat
(not (memq nil (mapcar (lambda (fn)
(funcall fn uconf-stat))
filter)))
(lyskom-read-conf-internal-verify-type
(uconf-stat->conf-no uconf-stat)
(uconf-stat->conf-type uconf-stat)
predicate nil nil)))
(mapcar (lambda (conf-no)
(blocking-do 'get-uconf-stat conf-no))
(apply 'append (delq nil (mapcar 'funcall default)))))))))
(car
(filter-list
(lambda (uconf-stat)
(and uconf-stat
(not (memq nil
(mapcar (lambda (fn)
(funcall fn uconf-stat))
filter)))
(lyskom-read-conf-internal-verify-type
(uconf-stat->conf-no uconf-stat)
(uconf-stat->conf-type uconf-stat)
predicate nil nil)))
(mapcar (lambda (conf-no)
(blocking-do 'get-uconf-stat conf-no))
(apply 'append
(delq nil (mapcar (lambda (fn)
(if (listp fn)
(apply (car fn) (cdr fn))
(funcall fn)))
default)))))))))
(defun lyskom-read-conf-save-input (prompt input)
"Save INPUT as input for the current completing read command."
(lyskom-traverse sym (cdr (assq 'save
(lyskom-get-initial-conf-strategy prompt)))
(if (assq sym lyskom-read-conf-saved-inputs)
(setcdr (assq sym lyskom-read-conf-saved-inputs) input)
(setq lyskom-read-conf-saved-inputs
(cons (cons sym input) lyskom-read-conf-saved-inputs))
)))
(defun lyskom-read-conf (prompt type &optional empty initial mustmatch)
"Completing read a conference or person from the minibuffer.
......@@ -300,20 +323,21 @@ A string: A name that matched nothing in the database."
((lyskom-read-conf-guess-initial prompt type))
(t nil)))
(setq prompt (cond ((stringp prompt) prompt)
((symbolp prompt) (lyskom-get-string prompt))
((listp prompt) (apply 'lyskom-format prompt))
(t (lyskom-get-string 'conf-prompt))))
(let* ((completion-ignore-case t)
(minibuffer-local-completion-map
lyskom-minibuffer-local-completion-map)
(minibuffer-local-must-match-map
lyskom-minibuffer-local-must-match-map)
(read-string nil)
(old-prompt prompt)
(result nil)
(keep-going t))
(setq prompt (cond ((stringp prompt) prompt)
((symbolp prompt) (lyskom-get-string prompt))
((listp prompt) (apply 'lyskom-format prompt))
(t (lyskom-get-string 'conf-prompt))))
(while keep-going
(setq read-string (lyskom-completing-read prompt
'lyskom-read-conf-internal
......@@ -329,6 +353,7 @@ A string: A name that matched nothing in the database."
(t (lyskom-lookup-conf-by-name read-string type))))
(setq keep-going (and (not empty)
(null result))))
(lyskom-read-conf-save-input old-prompt result)
result))
......
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