- 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)
(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:
(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)
(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.
(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.
(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
(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