From 31d783c2bea1b61c939b89c809f55bb758238c77 Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Mon, 22 Dec 2008 03:07:45 +0100 Subject: [PATCH] FUEL: Edit word's documentation command. --- extra/fuel/fuel.factor | 13 +++++++++---- misc/fuel/README | 3 ++- misc/fuel/factor-mode.el | 5 +++-- misc/fuel/fuel-base.el | 2 +- misc/fuel/fuel-mode.el | 23 ++++++++++++++++++++--- 5 files changed, 35 insertions(+), 11 deletions(-) diff --git a/extra/fuel/fuel.factor b/extra/fuel/fuel.factor index 51f04450c3..93cd4f9076 100644 --- a/extra/fuel/fuel.factor +++ b/extra/fuel/fuel.factor @@ -149,16 +149,21 @@ M: source-file fuel-pprint path>> fuel-pprint ; ! Edit locations +: fuel-normalize-loc ( seq -- path line ) + dup length 1 > [ first2 [ (normalize-path) ] dip ] [ f ] if ; inline + : fuel-get-edit-location ( defspec -- ) - where [ - first2 [ (normalize-path) ] dip 2array fuel-eval-set-result - ] when* ; inline + where fuel-normalize-loc 2array fuel-eval-set-result ; inline + +: fuel-get-doc-location ( defspec -- ) + props>> "help-loc" swap at + fuel-normalize-loc 2array fuel-eval-set-result ; : fuel-format-xrefs ( seq -- seq ) [ word? ] filter [ [ name>> ] [ vocabulary>> ] - [ where [ first2 [ (normalize-path) ] dip ] [ f f ] if* ] tri 4array + [ where fuel-normalize-loc ] tri 4array ] map [ [ first ] dip first <=> ] sort ; inline : fuel-callers-xref ( word -- ) diff --git a/misc/fuel/README b/misc/fuel/README index 72cba3b482..ee835f2c5c 100644 --- a/misc/fuel/README +++ b/misc/fuel/README @@ -58,7 +58,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 (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-M-r, C-cC-ee : eval region, extending it to definition boundaries diff --git a/misc/fuel/factor-mode.el b/misc/fuel/factor-mode.el index 7f129cd866..d354fd820a 100644 --- a/misc/fuel/factor-mode.el +++ b/misc/fuel/factor-mode.el @@ -24,8 +24,9 @@ ;;; Customization: (defgroup factor-mode nil - "Major mode for Factor source code" - :group 'fuel) + "Major mode for Factor source code." + :group 'fuel + :group 'languages) (defcustom factor-mode-use-fuel t "Whether to use the full FUEL facilities in factor mode. diff --git a/misc/fuel/fuel-base.el b/misc/fuel/fuel-base.el index 1f946bede6..219f821daa 100644 --- a/misc/fuel/fuel-base.el +++ b/misc/fuel/fuel-base.el @@ -26,7 +26,7 @@ ;;;###autoload (defgroup fuel nil "Factor's Ultimate Emacs Library." - :group 'language) + :group 'languages) ;;; Emacs compatibility: diff --git a/misc/fuel/fuel-mode.el b/misc/fuel/fuel-mode.el index 812f1e5b2b..608072c87a 100644 --- a/misc/fuel/fuel-mode.el +++ b/misc/fuel/fuel-mode.el @@ -135,12 +135,28 @@ buffer in case of errors." 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-edit-location)))) + (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))))) +(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) (defun fuel-edit-word (&optional arg) @@ -152,7 +168,7 @@ offered." nil fuel-mode--word-history 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)))) (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 (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 ?l 'fuel-run-file) (fuel-mode--key ?e ?r 'fuel-eval-region)