Merge branch 'emacs' of http://git.hacks-galore.org/jao/factor
commit
0c3ddf9f15
|
@ -122,6 +122,7 @@ beast.
|
||||||
- C-cC-xr : extract region as a separate word
|
- C-cC-xr : extract region as a separate word
|
||||||
- C-cC-xi : replace word at point by its definition
|
- C-cC-xi : replace word at point by its definition
|
||||||
- C-cC-xv : extract region as a separate vocabulary
|
- C-cC-xv : extract region as a separate vocabulary
|
||||||
|
- C-cC-xw : rename all uses of a word
|
||||||
|
|
||||||
*** In the listener:
|
*** In the listener:
|
||||||
|
|
||||||
|
|
|
@ -198,10 +198,11 @@ interacting with a factor listener is at your disposal.
|
||||||
(fuel-mode--key ?e ?w 'fuel-edit-word)
|
(fuel-mode--key ?e ?w 'fuel-edit-word)
|
||||||
(fuel-mode--key ?e ?x 'fuel-eval-definition)
|
(fuel-mode--key ?e ?x 'fuel-eval-definition)
|
||||||
|
|
||||||
(fuel-mode--key ?x ?s 'fuel-refactor-extract-sexp)
|
|
||||||
(fuel-mode--key ?x ?r 'fuel-refactor-extract-region)
|
|
||||||
(fuel-mode--key ?x ?v 'fuel-refactor-extract-vocab)
|
|
||||||
(fuel-mode--key ?x ?i 'fuel-refactor-inline-word)
|
(fuel-mode--key ?x ?i 'fuel-refactor-inline-word)
|
||||||
|
(fuel-mode--key ?x ?r 'fuel-refactor-extract-region)
|
||||||
|
(fuel-mode--key ?x ?s 'fuel-refactor-extract-sexp)
|
||||||
|
(fuel-mode--key ?x ?v 'fuel-refactor-extract-vocab)
|
||||||
|
(fuel-mode--key ?x ?w 'fuel-refactor-rename-word)
|
||||||
|
|
||||||
(fuel-mode--key ?d ?> 'fuel-show-callees)
|
(fuel-mode--key ?d ?> 'fuel-show-callees)
|
||||||
(fuel-mode--key ?d ?< 'fuel-show-callers)
|
(fuel-mode--key ?d ?< 'fuel-show-callers)
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
(require 'fuel-syntax)
|
(require 'fuel-syntax)
|
||||||
(require 'fuel-base)
|
(require 'fuel-base)
|
||||||
|
|
||||||
|
(require 'etags)
|
||||||
|
|
||||||
|
|
||||||
;;; Word definitions in buffer
|
;;; Word definitions in buffer
|
||||||
|
|
||||||
|
@ -167,7 +169,28 @@ word."
|
||||||
|
|
||||||
;;; Rename word:
|
;;; Rename word:
|
||||||
|
|
||||||
|
(defsubst fuel-refactor--rename-word (from to file)
|
||||||
|
(let ((files (fuel-xref--word-callers-files from)))
|
||||||
|
(tags-query-replace from to t `(cons ,file ',files))
|
||||||
|
files))
|
||||||
|
|
||||||
|
(defun fuel-refactor--def-word ()
|
||||||
|
(save-excursion
|
||||||
|
(fuel-syntax--beginning-of-defun)
|
||||||
|
(or (and (looking-at fuel-syntax--method-definition-regex)
|
||||||
|
(match-string-no-properties 2))
|
||||||
|
(and (looking-at fuel-syntax--word-definition-regex)
|
||||||
|
(match-string-no-properties 2)))))
|
||||||
|
|
||||||
|
(defun fuel-refactor-rename-word (&optional arg)
|
||||||
|
"Rename globally the word whose definition point is at.
|
||||||
|
With prefix argument, use word at point instead."
|
||||||
|
(interactive "P")
|
||||||
|
(let* ((from (if arg (fuel-syntax-symbol-at-point) (fuel-refactor--def-word)))
|
||||||
|
(from (read-string "Rename word: " from))
|
||||||
|
(to (read-string (format "Rename '%s' to: " from)))
|
||||||
|
(buffer (current-buffer)))
|
||||||
|
(fuel-refactor--rename-word from to (buffer-file-name))))
|
||||||
|
|
||||||
|
|
||||||
;;; Extract vocab:
|
;;; Extract vocab:
|
||||||
|
|
|
@ -244,7 +244,8 @@
|
||||||
;; Comments:
|
;; Comments:
|
||||||
("\\_<\\(#?!\\) .*\\(\n\\|$\\)" (1 "<") (2 ">"))
|
("\\_<\\(#?!\\) .*\\(\n\\|$\\)" (1 "<") (2 ">"))
|
||||||
("\\_<\\(#?!\\)\\(\n\\|$\\)" (1 "<") (2 ">"))
|
("\\_<\\(#?!\\)\\(\n\\|$\\)" (1 "<") (2 ">"))
|
||||||
("\\_<\\((\\) \\([^)\n]*?\\) \\()\\)\\_>" (1 "<b") (2 "w") (3 ">b"))
|
(" \\((\\)( \\([^\n]*\\) )\\()\\)\\( \\|\n\\)" (1 "<b") (2 "w") (3 ">b"))
|
||||||
|
(" \\((\\) \\([^\n]*\\) \\()\\)\\( \\|\n\\)" (1 "<b") (2 "w") (3 ">b"))
|
||||||
;; Strings
|
;; Strings
|
||||||
("\\( \\|^\\)\\(\"\\)[^\n\r\f]*\\(\"\\)\\( \\|\n\\)" (2 "\"") (3 "\""))
|
("\\( \\|^\\)\\(\"\\)[^\n\r\f]*\\(\"\\)\\( \\|\n\\)" (2 "\"") (3 "\""))
|
||||||
("\\_<<\\(\"\\)\\_>" (1 "<b"))
|
("\\_<<\\(\"\\)\\_>" (1 "<b"))
|
||||||
|
|
|
@ -128,11 +128,17 @@ cursor at the first ocurrence of the used word."
|
||||||
(message "")
|
(message "")
|
||||||
(fuel-popup--display (fuel-xref--buffer)))))
|
(fuel-popup--display (fuel-xref--buffer)))))
|
||||||
|
|
||||||
|
(defun fuel-xref--callers (word)
|
||||||
|
(let ((cmd `(:fuel* (((:quote ,word) fuel-callers-xref)))))
|
||||||
|
(fuel-eval--retort-result (fuel-eval--send/wait cmd))))
|
||||||
|
|
||||||
(defun fuel-xref--show-callers (word)
|
(defun fuel-xref--show-callers (word)
|
||||||
(let* ((cmd `(:fuel* (((:quote ,word) fuel-callers-xref))))
|
(let ((refs (fuel-xref--callers word)))
|
||||||
(res (fuel-eval--retort-result (fuel-eval--send/wait cmd))))
|
|
||||||
(with-current-buffer (fuel-xref--buffer) (setq fuel-xref--word word))
|
(with-current-buffer (fuel-xref--buffer) (setq fuel-xref--word word))
|
||||||
(fuel-xref--fill-and-display word "using" res)))
|
(fuel-xref--fill-and-display word "using" refs)))
|
||||||
|
|
||||||
|
(defun fuel-xref--word-callers-files (word)
|
||||||
|
(mapcar 'third (fuel-xref--callers word)))
|
||||||
|
|
||||||
(defun fuel-xref--show-callees (word)
|
(defun fuel-xref--show-callees (word)
|
||||||
(let* ((cmd `(:fuel* (((:quote ,word) fuel-callees-xref))))
|
(let* ((cmd `(:fuel* (((:quote ,word) fuel-callees-xref))))
|
||||||
|
|
Loading…
Reference in New Issue