annotate elpa/elpy-1.25.0/elpy-refactor.el @ 182:c3bd84985977

upgrade elpy to 1.25
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Thu, 11 Oct 2018 15:38:33 -0400
parents elpa/elpy-1.18.0/elpy-refactor.el@56ea66d76309
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
98
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
1 ;;; elpy-refactor.el --- Refactoring mode for Elpy
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
2
152
55ceabc58fcc elpy: upgrade to 1.12
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 126
diff changeset
3 ;; Copyright (C) 2013-2016 Jorgen Schaefer
98
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
4
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
5 ;; Author: Jorgen Schaefer <contact@jorgenschaefer.de>
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
6 ;; URL: https://github.com/jorgenschaefer/elpy
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
7
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
8 ;; This program is free software; you can redistribute it and/or
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
9 ;; modify it under the terms of the GNU General Public License
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
10 ;; as published by the Free Software Foundation; either version 3
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
11 ;; of the License, or (at your option) any later version.
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
12
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
13 ;; This program is distributed in the hope that it will be useful,
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
16 ;; GNU General Public License for more details.
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
17
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
20
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
21 ;;; Commentary:
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
22
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
23 ;; This file provides an interface, including a major mode, to use
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
24 ;; refactoring options provided by the Rope library.
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
25
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
26 ;;; Code:
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
27
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
28 ;; We require elpy, but elpy loads us, so we shouldn't load it back.
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
29 ;; (require 'elpy)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
30
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
31 (defvar elpy-refactor-changes nil
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
32 "Changes that will be commited on \\[elpy-refactor-commit].")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
33 (make-variable-buffer-local 'elpy-refactor-current-changes)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
34
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
35 (defvar elpy-refactor-window-configuration nil
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
36 "The old window configuration. Will be restored after commit.")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
37 (make-variable-buffer-local 'elpy-refactor-window-configuration)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
38
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
39 (make-obsolete
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
40 'elpy-refactor
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
41 "Refactoring has been unstable and flakey, support will be dropped in the future."
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
42 "elpy 1.5.0")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
43 (defun elpy-refactor ()
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
44 "Run the Elpy refactoring interface for Python code."
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
45 (interactive)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
46 (save-some-buffers)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
47 (let* ((selection (elpy-refactor-select
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
48 (elpy-refactor-rpc-get-options)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
49 (method (car selection))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
50 (args (cdr selection)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
51 (when method
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
52 (elpy-refactor-create-change-buffer
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
53 (elpy-refactor-rpc-get-changes method args)))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
54
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
55 (defun elpy-refactor-select (options)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
56 "Show the user the refactoring options and let her choose one.
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
57
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
58 Depending on the chosen option, ask the user for further
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
59 arguments and build the argument.
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
60
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
61 Return a cons cell of the name of the option and the arg list
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
62 created."
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
63 (let ((buf (get-buffer-create "*Elpy Refactor*"))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
64 (pos (vector (1- (point))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
65 (ignore-errors
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
66 (1- (region-beginning)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
67 (ignore-errors
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
68 (1- (region-end)))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
69 (inhibit-read-only t)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
70 (options (sort options
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
71 (lambda (a b)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
72 (let ((cata (cdr (assq 'category a)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
73 (catb (cdr (assq 'category b))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
74 (if (equal cata catb)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
75 (string< (cdr (assq 'description a))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
76 (cdr (assq 'description b)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
77 (string< cata catb))))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
78 (key ?a)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
79 last-category
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
80 option-alist)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
81 (with-current-buffer buf
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
82 (erase-buffer)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
83 (dolist (option options)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
84 (let ((category (cdr (assq 'category option)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
85 (description (cdr (assq 'description option)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
86 (name (cdr (assq 'name option)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
87 (args (cdr (assq 'args option))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
88 (when (not (equal category last-category))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
89 (when last-category
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
90 (insert "\n"))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
91 (insert (propertize category 'face 'bold) "\n")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
92 (setq last-category category))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
93 (insert " (" key ") " description "\n")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
94 (setq option-alist (cons (list key name args)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
95 option-alist))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
96 (setq key (1+ key))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
97 (let ((window-conf (current-window-configuration)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
98 (unwind-protect
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
99 (progn
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
100 (with-selected-window (display-buffer buf)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
101 (goto-char (point-min)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
102 (fit-window-to-buffer (get-buffer-window buf))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
103 (let* ((key (read-key "Refactoring action? "))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
104 (entry (cdr (assoc key option-alist))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
105 (kill-buffer buf)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
106 (cons (car entry) ; name
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
107 (elpy-refactor-build-arguments (cadr entry)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
108 pos))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
109 (set-window-configuration window-conf))))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
110
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
111 (defun elpy-refactor-build-arguments (args pos)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
112 "Translate an argument list specification to an argument list.
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
113
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
114 POS is a vector of three elements, the current offset, the offset
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
115 of the beginning of the region, and the offset of the end of the
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
116 region.
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
117
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
118 ARGS is a list of triples, each triple containing the name of an
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
119 argument (ignored), the type of the argument, and a possible
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
120 prompt string.
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
121
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
122 Available types:
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
123
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
124 offset - The offset in the buffer, (1- (point))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
125 start_offset - Offset of the beginning of the region
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
126 end_offset - Offset of the end of the region
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
127 string - A free-form string
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
128 filename - A non-existing file name
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
129 directory - An existing directory name
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
130 boolean - A boolean question"
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
131 (mapcar (lambda (arg)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
132 (let ((type (cadr arg))
182
c3bd84985977 upgrade elpy to 1.25
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 175
diff changeset
133 (prompt (cl-caddr arg)))
98
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
134 (cond
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
135 ((equal type "offset")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
136 (aref pos 0))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
137 ((equal type "start_offset")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
138 (aref pos 1))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
139 ((equal type "end_offset")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
140 (aref pos 2))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
141 ((equal type "string")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
142 (read-from-minibuffer prompt))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
143 ((equal type "filename")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
144 (expand-file-name
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
145 (read-file-name prompt)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
146 ((equal type "directory")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
147 (expand-file-name
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
148 (read-directory-name prompt)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
149 ((equal type "boolean")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
150 (y-or-n-p prompt)))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
151 args))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
152
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
153 (defun elpy-refactor-create-change-buffer (changes)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
154 "Show the user a buffer of changes.
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
155
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
156 The user can review the changes and confirm them with
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
157 \\[elpy-refactor-commit]."
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
158 (when (not changes)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
159 (error "No changes for this refactoring action."))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
160 (with-current-buffer (get-buffer-create "*Elpy Refactor*")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
161 (elpy-refactor-mode)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
162 (setq elpy-refactor-changes changes
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
163 elpy-refactor-window-configuration (current-window-configuration))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
164 (let ((inhibit-read-only t))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
165 (erase-buffer)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
166 (elpy-refactor-insert-changes changes))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
167 (select-window (display-buffer (current-buffer)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
168 (goto-char (point-min))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
169
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
170 (defun elpy-refactor-insert-changes (changes)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
171 "Format and display the changes described in CHANGES."
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
172 (insert (propertize "Use C-c C-c to apply the following changes."
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
173 'face 'bold)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
174 "\n\n")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
175 (dolist (change changes)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
176 (let ((action (cdr (assq 'action change))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
177 (cond
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
178 ((equal action "change")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
179 (insert (cdr (assq 'diff change))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
180 "\n"))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
181 ((equal action "create")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
182 (let ((type (cdr (assq 'type change))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
183 (if (equal type "file")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
184 (insert "+++ " (cdr (assq 'file change)) "\n"
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
185 "Create file " (cdr (assq 'file change)) "\n"
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
186 "\n")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
187 (insert "+++ " (cdr (assq 'path change)) "\n"
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
188 "Create directory " (cdr (assq 'path change)) "\n"
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
189 "\n"))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
190 ((equal action "move")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
191 (insert "--- " (cdr (assq 'source change)) "\n"
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
192 "+++ " (cdr (assq 'destination change)) "\n"
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
193 "Rename " (cdr (assq 'type change)) "\n"
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
194 "\n"))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
195 ((equal action "delete")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
196 (let ((type (cdr (assq 'type change))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
197 (if (equal type "file")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
198 (insert "--- " (cdr (assq 'file change)) "\n"
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
199 "Delete file " (cdr (assq 'file change)) "\n"
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
200 "\n")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
201 (insert "--- " (cdr (assq 'path change)) "\n"
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
202 "Delete directory " (cdr (assq 'path change)) "\n"
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
203 "\n"))))))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
204
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
205 (defvar elpy-refactor-mode-map
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
206 (let ((map (make-sparse-keymap)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
207 (define-key map (kbd "C-c C-c") 'elpy-refactor-commit)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
208 (define-key map (kbd "q") 'bury-buffer)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
209 (define-key map (kbd "h") 'describe-mode)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
210 (define-key map (kbd "?") 'describe-mode)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
211 map)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
212 "The key map for `elpy-refactor-mode'.")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
213
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
214 (define-derived-mode elpy-refactor-mode diff-mode "Elpy Refactor"
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
215 "Mode to display refactoring actions and ask confirmation from the user.
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
216
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
217 \\{elpy-refactor-mode-map}"
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
218 :group 'elpy
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
219 (view-mode 1))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
220
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
221 (defun elpy-refactor-commit ()
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
222 "Commit the changes in the current buffer."
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
223 (interactive)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
224 (when (not elpy-refactor-changes)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
225 (error "No changes to commit."))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
226 ;; Restore the window configuration as the first thing so that
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
227 ;; changes below are visible to the user. Especially the point
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
228 ;; change in possible buffer changes.
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
229 (set-window-configuration elpy-refactor-window-configuration)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
230 (dolist (change elpy-refactor-changes)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
231 (let ((action (cdr (assq 'action change))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
232 (cond
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
233 ((equal action "change")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
234 (with-current-buffer (find-file-noselect (cdr (assq 'file change)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
235 ;; This would break for save-excursion as the buffer is
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
236 ;; truncated, so all markets now point to position 1.
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
237 (let ((old-point (point)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
238 (undo-boundary)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
239 (erase-buffer)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
240 (insert (cdr (assq 'contents change)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
241 (undo-boundary)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
242 (goto-char old-point))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
243 ((equal action "create")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
244 (if (equal (cdr (assq 'type change))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
245 "file")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
246 (find-file-noselect (cdr (assq 'file change)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
247 (make-directory (cdr (assq 'path change)))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
248 ((equal action "move")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
249 (let* ((source (cdr (assq 'source change)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
250 (dest (cdr (assq 'destination change)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
251 (buf (get-file-buffer source)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
252 (when buf
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
253 (with-current-buffer buf
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
254 (setq buffer-file-name dest)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
255 (rename-buffer (file-name-nondirectory dest) t)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
256 (rename-file source dest)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
257 ((equal action "delete")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
258 (if (equal (cdr (assq 'type change)) "file")
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
259 (let ((name (cdr (assq 'file change))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
260 (when (y-or-n-p (format "Really delete %s? " name))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
261 (delete-file name t)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
262 (let ((name (cdr (assq 'directory change))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
263 (when (y-or-n-p (format "Really delete %s? " name))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
264 (delete-directory name nil t))))))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
265 (kill-buffer (current-buffer)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
266
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
267 (defun elpy-refactor-rpc-get-options ()
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
268 "Get a list of refactoring options from the Elpy RPC."
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
269 (if (use-region-p)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
270 (elpy-rpc "get_refactor_options"
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
271 (list (buffer-file-name)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
272 (1- (region-beginning))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
273 (1- (region-end))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
274 (elpy-rpc "get_refactor_options"
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
275 (list (buffer-file-name)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
276 (1- (point))))))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
277
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
278 (defun elpy-refactor-rpc-get-changes (method args)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
279 "Get a list of changes from the Elpy RPC after applying METHOD with ARGS."
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
280 (elpy-rpc "refactor"
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
281 (list (buffer-file-name)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
282 method args)))
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
283
152
55ceabc58fcc elpy: upgrade to 1.12
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 126
diff changeset
284 (defun elpy-refactor-options (option)
55ceabc58fcc elpy: upgrade to 1.12
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 126
diff changeset
285 "Show available refactor options and let user choose one."
55ceabc58fcc elpy: upgrade to 1.12
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 126
diff changeset
286 (interactive "c[i]: importmagic-fixup [p]: autopep8-fix-code [r]: refactor")
55ceabc58fcc elpy: upgrade to 1.12
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 126
diff changeset
287 (let ((choice (char-to-string option)))
55ceabc58fcc elpy: upgrade to 1.12
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 126
diff changeset
288 (cond
55ceabc58fcc elpy: upgrade to 1.12
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 126
diff changeset
289 ((string-equal choice "i")
55ceabc58fcc elpy: upgrade to 1.12
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 126
diff changeset
290 (elpy-importmagic-fixup))
55ceabc58fcc elpy: upgrade to 1.12
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 126
diff changeset
291 ((string-equal choice "p")
55ceabc58fcc elpy: upgrade to 1.12
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 126
diff changeset
292 (elpy-autopep8-fix-code))
55ceabc58fcc elpy: upgrade to 1.12
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 126
diff changeset
293 ((string-equal choice "r")
55ceabc58fcc elpy: upgrade to 1.12
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 126
diff changeset
294 (elpy-refactor)))))
55ceabc58fcc elpy: upgrade to 1.12
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 126
diff changeset
295
98
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
296 (provide 'elpy-refactor)
156cbb54f344 Add elpy and deps
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff changeset
297 ;;; elpy-refactor.el ends here