]> gitweb.factorcode.org Git - factor.git/commitdiff
FUEL: Edit word's documentation command.
authorJose A. Ortega Ruiz <jao@gnu.org>
Mon, 22 Dec 2008 02:07:45 +0000 (03:07 +0100)
committerJose A. Ortega Ruiz <jao@gnu.org>
Mon, 22 Dec 2008 02:07:45 +0000 (03:07 +0100)
extra/fuel/fuel.factor
misc/fuel/README
misc/fuel/factor-mode.el
misc/fuel/fuel-base.el
misc/fuel/fuel-mode.el

index 51f04450c32966a6dc5e5ce33122866e36c75fd2..93cd4f90762bb12c0984370f0424e258f4abdcee 100644 (file)
@@ -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 -- )
index 72cba3b482b82a43b90719a2a74cc68f28b13925..ee835f2c5ca589d0d9204686de453962f164612a 100644 (file)
@@ -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
index 7f129cd866d69b59ec56a3271523c59e961389f5..d354fd820ae97bbb1f0ea6f0ff5ff930221e80c8 100644 (file)
@@ -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.
index 1f946bede6f617d923148d08f8b42b19293bc648..219f821daacbccfcdf67e791bb8cc485219bfd5c 100644 (file)
@@ -26,7 +26,7 @@
 ;;;###autoload
 (defgroup fuel nil
   "Factor's Ultimate Emacs Library."
-  :group 'language)
+  :group 'languages)
 
 \f
 ;;; Emacs compatibility:
index 812f1e5b2ba05dc5458149340be9ab7e3cd50f88..608072c87ac5ca0e9e3ecaf36e31152a241f678a 100644 (file)
@@ -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)