FUEL: Accept '?' in prompts for word and vocabs.
parent
e88812b76a
commit
9fd675a632
|
@ -18,6 +18,15 @@
|
|||
(require 'fuel-eval)
|
||||
(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:
|
||||
|
||||
|
@ -33,7 +42,8 @@
|
|||
fuel-completion--vocabs)
|
||||
|
||||
(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)))
|
||||
|
||||
(defsubst fuel-completion--vocab-list (prefix)
|
||||
|
@ -170,12 +180,21 @@ terminates a current completion."
|
|||
(cons completions partial)))
|
||||
|
||||
(defun fuel-completion--read-word (prompt &optional default history all)
|
||||
(completing-read prompt
|
||||
(if all fuel-completion--all-words-list-func
|
||||
fuel-completion--word-list-func)
|
||||
nil nil nil
|
||||
history
|
||||
(or default (fuel-syntax-symbol-at-point))))
|
||||
(let ((minibuffer-local-completion-map fuel-completion--minibuffer-map))
|
||||
(completing-read prompt
|
||||
(if all fuel-completion--all-words-list-func
|
||||
fuel-completion--word-list-func)
|
||||
nil nil nil
|
||||
history
|
||||
(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 ()
|
||||
"Complete the symbol at point.
|
||||
|
|
|
@ -57,13 +57,6 @@
|
|||
(fuel-edit--visit-file (car loc) fuel-edit-word-method)
|
||||
(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)
|
||||
(let ((cmd `(:fuel* (,name fuel-get-article-location) "fuel" t)))
|
||||
(fuel-edit--try-edit (fuel-eval--send/wait cmd))))
|
||||
|
@ -80,7 +73,7 @@
|
|||
When called interactively, asks for vocabulary with completion.
|
||||
With prefix argument, refreshes cached vocabulary list."
|
||||
(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)))
|
||||
(fuel-edit--try-edit (fuel-eval--send/wait cmd))))
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ buffer."
|
|||
|
||||
(defun fuel-help-vocab (vocab)
|
||||
"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))
|
||||
|
||||
(defun fuel-help-next (&optional forget-current)
|
||||
|
|
|
@ -282,7 +282,8 @@
|
|||
(fuel-markup--insert-newline)
|
||||
(dolist (s (cdr e))
|
||||
(fuel-markup--snippet (list '$snippet s))
|
||||
(newline)))
|
||||
(newline))
|
||||
(newline))
|
||||
|
||||
(defun fuel-markup--markup-example (e)
|
||||
(fuel-markup--insert-newline)
|
||||
|
|
|
@ -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."
|
||||
(interactive "P")
|
||||
(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)
|
||||
"fuel"))
|
||||
(ret (fuel-eval--send/wait cmd))
|
||||
|
|
|
@ -244,7 +244,7 @@ With prefix argument, force reload of vocabulary list."
|
|||
With prefix argument, ask for the vocab."
|
||||
(interactive "P")
|
||||
(let ((vocab (or (and (not arg) (fuel-syntax--current-vocab))
|
||||
(fuel-edit--read-vocabulary-name))))
|
||||
(fuel-completion--read-vocab nil))))
|
||||
(when vocab
|
||||
(fuel-xref--show-vocab-words vocab
|
||||
(fuel-syntax--file-has-private)))))
|
||||
|
|
Loading…
Reference in New Issue