FUEL: M-. improvements and new M-,.
parent
a70018bcc4
commit
0b36b8b259
|
@ -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)
|
||||
|
|
|
@ -17,6 +17,19 @@
|
|||
(require 'fuel-eval)
|
||||
(require 'fuel-base)
|
||||
|
||||
(require 'etags)
|
||||
|
||||
|
||||
;;; 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)))
|
||||
|
||||
|
||||
;;; 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")))
|
||||
|
||||
|
||||
(provide 'fuel-edit)
|
||||
;;; fuel-edit.el ends here
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue