]> gitweb.factorcode.org Git - factor.git/commitdiff
FUEL: M-. improvements and new M-,.
authorJose A. Ortega Ruiz <jao@gnu.org>
Tue, 13 Jan 2009 01:58:33 +0000 (02:58 +0100)
committerJose A. Ortega Ruiz <jao@gnu.org>
Tue, 13 Jan 2009 01:58:33 +0000 (02:58 +0100)
misc/fuel/README
misc/fuel/fuel-edit.el
misc/fuel/fuel-mode.el

index 41dabe564e079d125bb579a59944f677fb063661..5fed408bbf55715412a335043ebc1df7af8e1ceb 100644 (file)
@@ -80,7 +80,8 @@ beast.
     - C-cz : switch to listener
     - C-co : cycle between code, tests and docs factor files
 
-    - M-. : edit word at point in Emacs
+    - M-. : edit word at point in Emacs (see fuel-edit-word-method custom var)
+    - M-, : go back to where M-. was last invoked
     - M-TAB : complete word at point
     - C-cC-eu : update USING: line
     - C-cC-ev : edit vocabulary (M-x fuel-edit-vocabulary)
index e5988d139277b614e426282bcd3dca3fe6ab93b4..20e1f1eb013796e9e3a697fba5a006a12c82dfe5 100644 (file)
 (require 'fuel-eval)
 (require 'fuel-base)
 
+(require 'etags)
+
+\f
+;;; Customization
+
+(defcustom fuel-edit-word-method nil
+  "How the new buffer is opened when invoking
+\\[fuel-edit-word-at-point]."
+  :group 'fuel
+  :type '(choice (const :tag "Other window" window)
+                 (const :tag "Other frame" frame)
+                 (const :tag "Current window" nil)))
+
 \f
 ;;; Auxiliar functions:
 
@@ -27,7 +40,9 @@
       (error "Couldn't find edit location"))
     (unless (file-readable-p (car loc))
       (error "Couldn't open '%s' for read" (car loc)))
-    (find-file-other-window (car loc))
+    (cond ((eq fuel-edit-word-method 'window) (find-file-other-window (car loc)))
+          ((eq fuel-edit-word-method 'frame) (find-file-other-frame (car loc)))
+          (t (find-file (car loc))))
     (goto-line (if (numberp (cadr loc)) (cadr loc) 1))))
 
 (defun fuel-edit--read-vocabulary-name (refresh)
@@ -46,6 +61,7 @@
 
 (defvar fuel-edit--word-history nil)
 (defvar fuel-edit--vocab-history nil)
+(defvar fuel-edit--previous-location nil)
 
 (defun fuel-edit-vocabulary (&optional refresh vocab)
   "Visits vocabulary file in Emacs.
@@ -74,10 +90,12 @@ 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))))
+         (cmd `(:fuel* ((:quote ,word) fuel-get-edit-location)))
+         (marker (and (not arg) (point-marker))))
     (condition-case nil
         (fuel-edit--try-edit (fuel-eval--send/wait cmd))
-      (error (fuel-edit-vocabulary nil word)))))
+      (error (fuel-edit-vocabulary nil word)))
+    (when marker (ring-insert find-tag-marker-ring marker))))
 
 (defun fuel-edit-word-doc-at-point (&optional arg word)
   "Opens a new window visiting the documentation file for the word at point.
@@ -86,7 +104,8 @@ With prefix, asks for the word to edit."
   (let* ((word (or word
                    (and (not arg) (fuel-syntax-symbol-at-point))
                    (fuel-completion--read-word "Edit word: ")))
-         (cmd `(:fuel* ((:quote ,word) fuel-get-doc-location))))
+         (cmd `(:fuel* ((:quote ,word) fuel-get-doc-location)))
+         (marker (and (not arg) (point-marker))))
     (condition-case nil
         (fuel-edit--try-edit (fuel-eval--send/wait cmd))
       (error
@@ -95,10 +114,19 @@ With prefix, asks for the word to edit."
                   (y-or-n-p (concat "No documentation found. "
                                     "Do you want to open the vocab's "
                                     "doc file? ")))
+         (when marker (ring-insert find-tag-marker-ring marker))
          (find-file-other-window
           (format "%s-docs.factor"
                   (file-name-sans-extension (buffer-file-name)))))))))
 
+(defun fuel-edit-pop-edit-word-stack ()
+  "Pop back to where \\[fuel-edit-word-at-point] or \\[fuel-edit-word-doc-at-point]
+was last invoked."
+  (interactive)
+  (condition-case nil
+      (pop-tag-mark)
+    (error "No previous location for find word or vocab invokation")))
+
 \f
 (provide 'fuel-edit)
 ;;; fuel-edit.el ends here
index ed0104d1cb1a5b8a124908aa45b3e79a4983ae6f..0b863507ff7e1ba5534c71b71001b575b39fcf28 100644 (file)
@@ -181,6 +181,7 @@ interacting with a factor listener is at your disposal.
 (define-key fuel-mode-map "\C-\M-x" 'fuel-eval-definition)
 (define-key fuel-mode-map "\C-\M-r" 'fuel-eval-extended-region)
 (define-key fuel-mode-map "\M-." 'fuel-edit-word-at-point)
+(define-key fuel-mode-map "\M-," 'fuel-edit-pop-edit-word-stack)
 (define-key fuel-mode-map "\C-c\M-<" 'fuel-show-callers)
 (define-key fuel-mode-map "\C-c\M->" 'fuel-show-callees)
 (define-key fuel-mode-map (kbd "M-TAB") 'fuel-completion--complete-symbol)