Slava Pestov 2009-02-09 01:57:17 -06:00
commit cbe86577d4
8 changed files with 41 additions and 23 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,23 @@ 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)))))
(defvar fuel-completion--vocab-history nil)
(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-completion--vocab-history)
(read-string prompt nil fuel-completion--vocab-history))))
(defun fuel-completion--complete-symbol () (defun fuel-completion--complete-symbol ()
"Complete the symbol at point. "Complete the symbol at point.

View File

@ -144,8 +144,12 @@
(add-hook 'comint-redirect-hook (add-hook 'comint-redirect-hook
'fuel-con--comint-redirect-hook nil t)) 'fuel-con--comint-redirect-hook nil t))
(defadvice comint-redirect-setup (after fuel-con--advice activate) (defadvice comint-redirect-setup
(setq comint-redirect-finished-regexp fuel-con--comint-finished-regex)) (after fuel-con--advice (output-buffer comint-buffer finished-regexp &optional echo))
(with-current-buffer comint-buffer
(when fuel-con--connection
(setq comint-redirect-finished-regexp fuel-con--comint-finished-regex))))
(ad-activate 'comint-redirect-setup)
(defun fuel-con--comint-preoutput-filter (str) (defun fuel-con--comint-preoutput-filter (str)
(when (string-match fuel-con--comint-finished-regex str) (when (string-match fuel-con--comint-finished-regex str)

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))))
@ -72,7 +65,6 @@
;;; Editing commands: ;;; Editing commands:
(defvar fuel-edit--word-history nil) (defvar fuel-edit--word-history nil)
(defvar fuel-edit--vocab-history nil)
(defvar fuel-edit--previous-location nil) (defvar fuel-edit--previous-location nil)
(defun fuel-edit-vocabulary (&optional refresh vocab) (defun fuel-edit-vocabulary (&optional refresh vocab)
@ -80,7 +72,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

@ -32,7 +32,7 @@
(defcustom fuel-listener-factor-binary (defcustom fuel-listener-factor-binary
(expand-file-name (cond ((eq system-type 'windows-nt) (expand-file-name (cond ((eq system-type 'windows-nt)
"factor.exe") "factor.com")
((eq system-type 'darwin) ((eq system-type 'darwin)
"Factor.app/Contents/MacOS/factor") "Factor.app/Contents/MacOS/factor")
(t "factor")) (t "factor"))

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)))))