FUEL: Edit word interactive command; completion in help prompt.
parent
7172a00f21
commit
e13adc4db0
|
@ -57,7 +57,8 @@ C-cC-eC-r is the same as C-cC-er)).
|
|||
|
||||
- M-. : edit word at point in Emacs
|
||||
- M-TAB : complete word at point
|
||||
- C-cC-ev : edit vocabulary
|
||||
- C-cC-ev : edit vocabulary (M-x fuel-edit-vocabulary)
|
||||
- C-cC-ew : edit word (M-x fuel-edit-word)
|
||||
|
||||
- C-cr, C-cC-er : eval region
|
||||
- C-M-r, C-cC-ee : eval region, extending it to definition boundaries
|
||||
|
|
|
@ -143,6 +143,15 @@ terminates a current completion."
|
|||
(vs (and cv `("syntax" ,cv ,@(fuel-syntax--usings)))))
|
||||
(fuel-completion--words prefix vs)))
|
||||
|
||||
(defsubst fuel-completion--all-words-list (prefix)
|
||||
(fuel-completion--words prefix nil))
|
||||
|
||||
(defvar fuel-completion--word-list-func
|
||||
(completion-table-dynamic 'fuel-completion--word-list))
|
||||
|
||||
(defvar fuel-completion--all-words-list-func
|
||||
(completion-table-dynamic 'fuel-completion--all-words-list))
|
||||
|
||||
(defun fuel-completion--complete (prefix)
|
||||
(let* ((words (fuel-completion--word-list prefix))
|
||||
(completions (all-completions prefix words))
|
||||
|
@ -150,6 +159,14 @@ terminates a current completion."
|
|||
(partial (if (eq partial t) prefix partial)))
|
||||
(cons completions partial)))
|
||||
|
||||
(defsubst 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))))
|
||||
|
||||
(defun fuel-completion--complete-symbol ()
|
||||
"Complete the symbol at point.
|
||||
Perform completion similar to Emacs' complete-symbol."
|
||||
|
|
|
@ -14,9 +14,10 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
(require 'fuel-base)
|
||||
(require 'fuel-font-lock)
|
||||
(require 'fuel-eval)
|
||||
(require 'fuel-completion)
|
||||
(require 'fuel-font-lock)
|
||||
(require 'fuel-base)
|
||||
|
||||
|
||||
;;; Customization:
|
||||
|
@ -149,7 +150,9 @@ displayed in the minibuffer."
|
|||
(ask (or (not (memq major-mode '(factor-mode fuel-help-mode)))
|
||||
(not def)
|
||||
fuel-help-always-ask))
|
||||
(def (if ask (read-string prompt nil 'fuel-help--prompt-history def)
|
||||
(def (if ask (fuel-completion--read-word prompt
|
||||
def
|
||||
'fuel-help--prompt-history)
|
||||
def))
|
||||
(cmd `(:fuel* ((:quote ,def) ,(if see 'see 'help)) t)))
|
||||
(message "Looking up '%s' ..." def)
|
||||
|
|
|
@ -114,18 +114,26 @@ buffer in case of errors."
|
|||
"Opens a new window visiting the definition of the word at point.
|
||||
With prefix, asks for the word to edit."
|
||||
(interactive "P")
|
||||
(let* ((word (fuel-syntax-symbol-at-point))
|
||||
(ask (or arg (not word)))
|
||||
(word (if ask
|
||||
(read-string nil
|
||||
(format "Edit word%s: "
|
||||
(if word (format " (%s)" word) ""))
|
||||
word)
|
||||
word)))
|
||||
(let ((cmd `(:fuel ((:quote ,word) fuel-get-edit-location))))
|
||||
(let* ((word (or (and (not arg) (fuel-syntax-symbol-at-point))
|
||||
(fuel-completion--read-word "Edit word: ")))
|
||||
(cmd `(:fuel ((:quote ,word) fuel-get-edit-location))))
|
||||
(condition-case nil
|
||||
(fuel--try-edit (fuel-eval--send/wait cmd))
|
||||
(error (fuel-edit-vocabulary nil word))))))
|
||||
(error (fuel-edit-vocabulary nil word)))))
|
||||
|
||||
(defvar fuel-mode--word-history nil)
|
||||
|
||||
(defun fuel-edit-word (&optional arg)
|
||||
"Asks for a word to edit, with completion.
|
||||
With prefix, only words visible in the current vocabulary are
|
||||
offered."
|
||||
(interactive "P")
|
||||
(let* ((word (fuel-completion--read-word "Edit word: "
|
||||
nil
|
||||
fuel-mode--word-history
|
||||
arg))
|
||||
(cmd `(:fuel ((:quote ,word) fuel-get-edit-location))))
|
||||
(fuel--try-edit (fuel-eval--send/wait cmd))))
|
||||
|
||||
(defvar fuel--vocabs-prompt-history nil)
|
||||
|
||||
|
@ -195,7 +203,7 @@ interacting with a factor listener is at your disposal.
|
|||
(fuel-mode--key ?e ?e 'fuel-eval-extended-region)
|
||||
(fuel-mode--key ?e ?r 'fuel-eval-region)
|
||||
(fuel-mode--key ?e ?v 'fuel-edit-vocabulary)
|
||||
(fuel-mode--key ?e ?w 'fuel-edit-word-at-point)
|
||||
(fuel-mode--key ?e ?w 'fuel-edit-word)
|
||||
(fuel-mode--key ?e ?x 'fuel-eval-definition)
|
||||
|
||||
(fuel-mode--key ?d ?a 'fuel-autodoc-mode)
|
||||
|
|
Loading…
Reference in New Issue