FUEL: Accept '?' in prompts for word and vocabs.

db4
Jose A. Ortega Ruiz 2009-02-05 10:28:57 +01:00
parent e88812b76a
commit 9fd675a632
6 changed files with 32 additions and 19 deletions

View File

@ -18,6 +18,15 @@
(require 'fuel-eval) (require 'fuel-eval)
(require 'fuel-log) (require 'fuel-log)
;;; Aux:
(defvar fuel-completion--minibuffer-map
(let ((map (make-keymap)))
(set-keymap-parent map minibuffer-local-completion-map)
(define-key map "?" 'self-insert-command)
map))
;;; Vocabs dictionary: ;;; Vocabs dictionary:
@ -33,7 +42,8 @@
fuel-completion--vocabs) fuel-completion--vocabs)
(defun fuel-completion--read-vocab (&optional reload init-input history) (defun fuel-completion--read-vocab (&optional reload init-input history)
(let ((vocabs (fuel-completion--vocabs reload))) (let ((minibuffer-local-completion-map fuel-completion--minibuffer-map)
(vocabs (fuel-completion--vocabs reload)))
(completing-read "Vocab name: " vocabs nil nil init-input history))) (completing-read "Vocab name: " vocabs nil nil init-input history)))
(defsubst fuel-completion--vocab-list (prefix) (defsubst fuel-completion--vocab-list (prefix)
@ -170,12 +180,21 @@ terminates a current completion."
(cons completions partial))) (cons completions partial)))
(defun fuel-completion--read-word (prompt &optional default history all) (defun fuel-completion--read-word (prompt &optional default history all)
(let ((minibuffer-local-completion-map fuel-completion--minibuffer-map))
(completing-read prompt (completing-read prompt
(if all fuel-completion--all-words-list-func (if all fuel-completion--all-words-list-func
fuel-completion--word-list-func) fuel-completion--word-list-func)
nil nil nil nil nil nil
history history
(or default (fuel-syntax-symbol-at-point)))) (or default (fuel-syntax-symbol-at-point)))))
(defun fuel-completion--read-vocab (refresh)
(let* ((minibuffer-local-completion-map fuel-completion--minibuffer-map)
(vocabs (fuel-completion--vocabs refresh))
(prompt "Vocabulary name: "))
(if vocabs
(completing-read prompt vocabs nil nil nil fuel-edit--vocab-history)
(read-string prompt nil fuel-edit--vocab-history))))
(defun fuel-completion--complete-symbol () (defun fuel-completion--complete-symbol ()
"Complete the symbol at point. "Complete the symbol at point.

View File

@ -57,13 +57,6 @@
(fuel-edit--visit-file (car loc) fuel-edit-word-method) (fuel-edit--visit-file (car loc) fuel-edit-word-method)
(goto-line (if (numberp (cadr loc)) (cadr loc) 1)))) (goto-line (if (numberp (cadr loc)) (cadr loc) 1))))
(defun fuel-edit--read-vocabulary-name (refresh)
(let* ((vocabs (fuel-completion--vocabs refresh))
(prompt "Vocabulary name: "))
(if vocabs
(completing-read prompt vocabs nil nil nil fuel-edit--vocab-history)
(read-string prompt nil fuel-edit--vocab-history))))
(defun fuel-edit--edit-article (name) (defun fuel-edit--edit-article (name)
(let ((cmd `(:fuel* (,name fuel-get-article-location) "fuel" t))) (let ((cmd `(:fuel* (,name fuel-get-article-location) "fuel" t)))
(fuel-edit--try-edit (fuel-eval--send/wait cmd)))) (fuel-edit--try-edit (fuel-eval--send/wait cmd))))
@ -80,7 +73,7 @@
When called interactively, asks for vocabulary with completion. When called interactively, asks for vocabulary with completion.
With prefix argument, refreshes cached vocabulary list." With prefix argument, refreshes cached vocabulary list."
(interactive "P") (interactive "P")
(let* ((vocab (or vocab (fuel-edit--read-vocabulary-name refresh))) (let* ((vocab (or vocab (fuel-completion--read-vocab refresh)))
(cmd `(:fuel* (,vocab fuel-get-vocab-location) "fuel" t))) (cmd `(:fuel* (,vocab fuel-get-vocab-location) "fuel" t)))
(fuel-edit--try-edit (fuel-eval--send/wait cmd)))) (fuel-edit--try-edit (fuel-eval--send/wait cmd))))

View File

@ -257,7 +257,7 @@ buffer."
(defun fuel-help-vocab (vocab) (defun fuel-help-vocab (vocab)
"Ask for a vocabulary name and show its help page." "Ask for a vocabulary name and show its help page."
(interactive (list (fuel-edit--read-vocabulary-name nil))) (interactive (list (fuel-completion--read-vocab nil)))
(fuel-help--get-vocab vocab)) (fuel-help--get-vocab vocab))
(defun fuel-help-next (&optional forget-current) (defun fuel-help-next (&optional forget-current)

View File

@ -282,7 +282,8 @@
(fuel-markup--insert-newline) (fuel-markup--insert-newline)
(dolist (s (cdr e)) (dolist (s (cdr e))
(fuel-markup--snippet (list '$snippet s)) (fuel-markup--snippet (list '$snippet s))
(newline))) (newline))
(newline))
(defun fuel-markup--markup-example (e) (defun fuel-markup--markup-example (e)
(fuel-markup--insert-newline) (fuel-markup--insert-newline)

View File

@ -71,7 +71,7 @@ You can configure `fuel-scaffold-developer-name' (set by default to
`user-full-name') for the name to be inserted in the generated file." `user-full-name') for the name to be inserted in the generated file."
(interactive "P") (interactive "P")
(let* ((vocab (or (and (not arg) (fuel-syntax--current-vocab)) (let* ((vocab (or (and (not arg) (fuel-syntax--current-vocab))
(fuel-edit--read-vocabulary-name nil))) (fuel-completion--read-vocab nil)))
(cmd `(:fuel* (,vocab ,fuel-scaffold-developer-name fuel-scaffold-help) (cmd `(:fuel* (,vocab ,fuel-scaffold-developer-name fuel-scaffold-help)
"fuel")) "fuel"))
(ret (fuel-eval--send/wait cmd)) (ret (fuel-eval--send/wait cmd))

View File

@ -244,7 +244,7 @@ With prefix argument, force reload of vocabulary list."
With prefix argument, ask for the vocab." With prefix argument, ask for the vocab."
(interactive "P") (interactive "P")
(let ((vocab (or (and (not arg) (fuel-syntax--current-vocab)) (let ((vocab (or (and (not arg) (fuel-syntax--current-vocab))
(fuel-edit--read-vocabulary-name)))) (fuel-completion--read-vocab nil))))
(when vocab (when vocab
(fuel-xref--show-vocab-words vocab (fuel-xref--show-vocab-words vocab
(fuel-syntax--file-has-private))))) (fuel-syntax--file-has-private)))))