Permalink
Browse files

interactive fixes

  • Loading branch information...
1 parent 28c7774 commit c5cb652d8496b01c8dacb88fe8074d8722f698d8 @joodie joodie committed Nov 3, 2011
Showing with 47 additions and 27 deletions.
  1. +20 −2 README.markdown
  2. +27 −25 clojure-refactoring-mode.el
View
@@ -34,7 +34,10 @@ Rename - Changes a name just in this sexp.
Emacs dependancies
---
-Slime, ido, a running clojure connection, paredit, and thing at point.
+Slime, a running clojure connection, paredit, and thing at point.
+
+Having ido-mode enabled is recommended when using
+clojure-refactoring-prompt.
Installation
---
@@ -53,7 +56,7 @@ Put clojure-refactoring-mode.el somewhere on your load path and add
(require 'clojure-refactoring-mode)
into your .emacs.
-Clojure-refactoring-ido will then be bound to C-c C-f.
+clojure-refactoring-prompt will then be bound to C-c C-f.
Note that global rename will be slow at first, as it has to read the
source files into a cached.
@@ -78,6 +81,21 @@ namespaces in the right order, so there is sometimes a null pointer
exception after doing this. For now, you can fix this by restarting
swank.
+Changes since 0.6.0
+---
+
+v0.6.2
+ - all refactorings are now implemented as interactive elisp
+ functions and take arguments where needed.
+ - ido is no longer required
+ - renamed clojure-refactoring-ido to clojure-refactoring-prompt
+
+v0.6.1
+ - bug fix release
+
+v0.6.0
+ - licensing updates, parsing fixes, general maintenance
+
License
---
Copyright (C) 2009-2010 Tom Crayford,
@@ -53,12 +53,17 @@
(setq clojure-refactoring-refactorings-list
(list "extract-fn" "thread-last" "extract-global" "thread-first" "unthread" "extract-local" "destructure-map" "rename" "global-rename"))
-(defun clojure-refactoring-ido ()
+(setq clojure-refactoring-refactorings-alist
+ (mapcar (lambda (refactoring) (list refactoring))
+ clojure-refactoring-refactorings-list))
+
+(defun clojure-refactoring-prompt ()
(interactive)
(if (and (fboundp 'slime-connected-p)
(slime-connected-p))
- (let ((refactoring (ido-completing-read "Refactoring: " clojure-refactoring-refactorings-list nil t)))
- (funcall (intern (concat "clojure-refactoring-" refactoring))))
+ (let ((refactoring (completing-read "Refactoring: " clojure-refactoring-refactorings-alist nil nil)))
+ (when (not (string= "" refactoring))
+ (call-interactively (intern (concat "clojure-refactoring-" refactoring)))))
(error "clojure-refactoring needs a SLIME connection.")))
(defun get-sexp ()
@@ -96,11 +101,10 @@
(defun clojure-refactoring-insert-sexp (s)
(insert (read s)))
-(defun clojure-refactoring-extract-fn ()
+(defun clojure-refactoring-extract-fn (fn-name)
"Extracts a function."
- (interactive)
- (let ((fn-name (read-from-minibuffer "Function name: "))
- (defn (slime-defun-at-point))
+ (interactive "sFunction name: ")
+ (let ((defn (slime-defun-at-point))
(body (get-sexp)))
(save-excursion
(beginning-of-defun)
@@ -137,11 +141,10 @@
(read-from-minibuffer "Old name: "
(symbol-name (symbol-at-point))))
-(defun clojure-refactoring-rename ()
- (interactive)
+(defun clojure-refactoring-rename (new-name)
+ (interactive "sNew name: ")
(save-excursion
- (let ((old-name (clojure-refactoring-read-symbol-at-point))
- (new-name (read-from-minibuffer "New name: ")))
+ (let ((old-name (clojure-refactoring-read-symbol-at-point)))
(beginning-of-defun)
(mark-sexp)
(let ((body (buffer-substring-no-properties (mark t) (point))))
@@ -157,10 +160,9 @@
(defun clojure-refactoring-reload-all-user-ns ()
(clojure-refactoring-eval-sync "(require 'clojure-refactoring.support.source)(clojure-refactoring.support.source/reload-all-user-ns)"))
-(defun clojure-refactoring-global-rename ()
- (interactive)
- (let ((old-name (clojure-refactoring-read-symbol-at-point))
- (new-name (read-from-minibuffer "New name: ")))
+(defun clojure-refactoring-global-rename (new-name)
+ (interactive "sNew name: ")
+ (let ((old-name (clojure-refactoring-read-symbol-at-point)))
(save-some-buffers 't)
(let ((expr (format "(require 'clojure-refactoring.rename) (ns clojure-refactoring.rename) (global-rename '%s '%s '%s)"
(slime-current-package) old-name new-name)))
@@ -170,9 +172,9 @@
(save-some-buffers 't)
(clojure-refactoring-reload-all-user-ns))
-(defun clojure-refactoring-extract-global ()
- (let ((var-name (read-from-minibuffer "Variable name: "))
- (body (delete-and-extract-region (mark t) (point))))
+(defun clojure-refactoring-extract-global (var-name)
+ (interactive "sVariable name: ")
+ (let ((body (delete-and-extract-region (mark t) (point))))
(save-excursion
(beginning-of-buffer)
(forward-sexp)
@@ -182,9 +184,9 @@
(paredit-mode 1))
(insert var-name)))
-(defun clojure-refactoring-extract-local ()
- (let ((var-name (read-from-minibuffer "Variable name: "))
- (defn (slime-defun-at-point))
+(defun clojure-refactoring-extract-local (var-name)
+ (interactive "sVarable name: ")
+ (let ((defn (slime-defun-at-point))
(body (get-sexp)))
(save-excursion
(beginning-of-defun)
@@ -197,9 +199,9 @@
body
var-name)))))
-(defun clojure-refactoring-destructure-map ()
- (let ((var-name (read-from-minibuffer "Map name: "))
- (defn (slime-defun-at-point)))
+(defun clojure-refactoring-destructure-map (map-name)
+ (interactive "sMap name: ")
+ (let ((defn (slime-defun-at-point)))
(save-excursion
(beginning-of-defun)
(forward-kill-sexp)
@@ -229,7 +231,7 @@
(defvar clojure-refactoring-mode-map
(let ((map (make-sparse-keymap)))
- (define-key map (kbd "C-c C-f") 'clojure-refactoring-ido)
+ (define-key map (kbd "C-c C-f") 'clojure-refactoring-prompt)
map)
"Keymap for Clojure refactoring mode.")

0 comments on commit c5cb652

Please sign in to comment.