FUEL: Edit word's documentation command.
parent
46d3667d4b
commit
31d783c2be
|
@ -149,16 +149,21 @@ M: source-file fuel-pprint path>> fuel-pprint ;
|
||||||
|
|
||||||
! Edit locations
|
! Edit locations
|
||||||
|
|
||||||
|
: fuel-normalize-loc ( seq -- path line )
|
||||||
|
dup length 1 > [ first2 [ (normalize-path) ] dip ] [ f ] if ; inline
|
||||||
|
|
||||||
: fuel-get-edit-location ( defspec -- )
|
: fuel-get-edit-location ( defspec -- )
|
||||||
where [
|
where fuel-normalize-loc 2array fuel-eval-set-result ; inline
|
||||||
first2 [ (normalize-path) ] dip 2array fuel-eval-set-result
|
|
||||||
] when* ; inline
|
: fuel-get-doc-location ( defspec -- )
|
||||||
|
props>> "help-loc" swap at
|
||||||
|
fuel-normalize-loc 2array fuel-eval-set-result ;
|
||||||
|
|
||||||
: fuel-format-xrefs ( seq -- seq )
|
: fuel-format-xrefs ( seq -- seq )
|
||||||
[ word? ] filter [
|
[ word? ] filter [
|
||||||
[ name>> ]
|
[ name>> ]
|
||||||
[ vocabulary>> ]
|
[ vocabulary>> ]
|
||||||
[ where [ first2 [ (normalize-path) ] dip ] [ f f ] if* ] tri 4array
|
[ where fuel-normalize-loc ] tri 4array
|
||||||
] map [ [ first ] dip first <=> ] sort ; inline
|
] map [ [ first ] dip first <=> ] sort ; inline
|
||||||
|
|
||||||
: fuel-callers-xref ( word -- )
|
: fuel-callers-xref ( word -- )
|
||||||
|
|
|
@ -58,7 +58,8 @@ C-cC-eC-r is the same as C-cC-er)).
|
||||||
- M-. : edit word at point in Emacs
|
- M-. : edit word at point in Emacs
|
||||||
- M-TAB : complete word at point
|
- M-TAB : complete word at point
|
||||||
- C-cC-ev : edit vocabulary (M-x fuel-edit-vocabulary)
|
- C-cC-ev : edit vocabulary (M-x fuel-edit-vocabulary)
|
||||||
- C-cC-ew : edit word (M-x fuel-edit-word)
|
- C-cC-ew : edit word (M-x fuel-edit-word-at-point)
|
||||||
|
- C-cC-ed : edit word's doc (M-x fuel-edit-word-at-point)
|
||||||
|
|
||||||
- C-cr, C-cC-er : eval region
|
- C-cr, C-cC-er : eval region
|
||||||
- C-M-r, C-cC-ee : eval region, extending it to definition boundaries
|
- C-M-r, C-cC-ee : eval region, extending it to definition boundaries
|
||||||
|
|
|
@ -24,8 +24,9 @@
|
||||||
;;; Customization:
|
;;; Customization:
|
||||||
|
|
||||||
(defgroup factor-mode nil
|
(defgroup factor-mode nil
|
||||||
"Major mode for Factor source code"
|
"Major mode for Factor source code."
|
||||||
:group 'fuel)
|
:group 'fuel
|
||||||
|
:group 'languages)
|
||||||
|
|
||||||
(defcustom factor-mode-use-fuel t
|
(defcustom factor-mode-use-fuel t
|
||||||
"Whether to use the full FUEL facilities in factor mode.
|
"Whether to use the full FUEL facilities in factor mode.
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defgroup fuel nil
|
(defgroup fuel nil
|
||||||
"Factor's Ultimate Emacs Library."
|
"Factor's Ultimate Emacs Library."
|
||||||
:group 'language)
|
:group 'languages)
|
||||||
|
|
||||||
|
|
||||||
;;; Emacs compatibility:
|
;;; Emacs compatibility:
|
||||||
|
|
|
@ -136,11 +136,27 @@ With prefix, asks for the word to edit."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(let* ((word (or (and (not arg) (fuel-syntax-symbol-at-point))
|
(let* ((word (or (and (not arg) (fuel-syntax-symbol-at-point))
|
||||||
(fuel-completion--read-word "Edit word: ")))
|
(fuel-completion--read-word "Edit word: ")))
|
||||||
(cmd `(:fuel ((:quote ,word) fuel-get-edit-location))))
|
(cmd `(:fuel* ((:quote ,word) fuel-get-edit-location))))
|
||||||
(condition-case nil
|
(condition-case nil
|
||||||
(fuel--try-edit (fuel-eval--send/wait cmd))
|
(fuel--try-edit (fuel-eval--send/wait cmd))
|
||||||
(error (fuel-edit-vocabulary nil word)))))
|
(error (fuel-edit-vocabulary nil word)))))
|
||||||
|
|
||||||
|
(defun fuel-edit-word-doc-at-point (&optional arg)
|
||||||
|
"Opens a new window visiting the documentation file for the word at point.
|
||||||
|
With prefix, asks for the word to edit."
|
||||||
|
(interactive "P")
|
||||||
|
(let* ((word (or (and (not arg) (fuel-syntax-symbol-at-point))
|
||||||
|
(fuel-completion--read-word "Edit word: ")))
|
||||||
|
(cmd `(:fuel* ((:quote ,word) fuel-get-doc-location))))
|
||||||
|
(condition-case nil
|
||||||
|
(fuel--try-edit (fuel-eval--send/wait cmd))
|
||||||
|
(error (when (y-or-n-p (concat "No documentation found. "
|
||||||
|
"Do you want to open the vocab's "
|
||||||
|
"doc file? "))
|
||||||
|
(find-file-other-window
|
||||||
|
(format "%s-docs.factor"
|
||||||
|
(file-name-sans-extension (buffer-file-name)))))))))
|
||||||
|
|
||||||
(defvar fuel-mode--word-history nil)
|
(defvar fuel-mode--word-history nil)
|
||||||
|
|
||||||
(defun fuel-edit-word (&optional arg)
|
(defun fuel-edit-word (&optional arg)
|
||||||
|
@ -152,7 +168,7 @@ offered."
|
||||||
nil
|
nil
|
||||||
fuel-mode--word-history
|
fuel-mode--word-history
|
||||||
arg))
|
arg))
|
||||||
(cmd `(:fuel ((:quote ,word) fuel-get-edit-location))))
|
(cmd `(:fuel* ((:quote ,word) fuel-get-edit-location))))
|
||||||
(fuel--try-edit (fuel-eval--send/wait cmd))))
|
(fuel--try-edit (fuel-eval--send/wait cmd))))
|
||||||
|
|
||||||
(defvar fuel--vocabs-prompt-history nil)
|
(defvar fuel--vocabs-prompt-history nil)
|
||||||
|
@ -250,6 +266,7 @@ interacting with a factor listener is at your disposal.
|
||||||
(define-key fuel-mode-map "\C-c\M->" 'fuel-show-callees)
|
(define-key fuel-mode-map "\C-c\M->" 'fuel-show-callees)
|
||||||
(define-key fuel-mode-map (kbd "M-TAB") 'fuel-completion--complete-symbol)
|
(define-key fuel-mode-map (kbd "M-TAB") 'fuel-completion--complete-symbol)
|
||||||
|
|
||||||
|
(fuel-mode--key ?e ?d 'fuel-edit-word-doc-at-point)
|
||||||
(fuel-mode--key ?e ?e 'fuel-eval-extended-region)
|
(fuel-mode--key ?e ?e 'fuel-eval-extended-region)
|
||||||
(fuel-mode--key ?e ?l 'fuel-run-file)
|
(fuel-mode--key ?e ?l 'fuel-run-file)
|
||||||
(fuel-mode--key ?e ?r 'fuel-eval-region)
|
(fuel-mode--key ?e ?r 'fuel-eval-region)
|
||||||
|
|
Loading…
Reference in New Issue