Skip to content

Commit 7ed0c9f

Browse files
authored
Merge pull request #24 from emacs-php/impl/context-menu
Impl phpactor-context-menu command
2 parents e0b131b + 725f15d commit 7ed0c9f

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

phpactor.el

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,10 @@
157157
(replace_file_source . phpactor-action-replace-file-source)))
158158

159159
;; Helper functions:
160-
(cl-defun phpactor--action-input-parameters (type &key default label choices)
160+
(cl-defun phpactor--action-input-parameters (value-type &key default label choices type)
161161
"Request user input by parameters."
162-
(let ((use-dialog-box nil))
162+
(let ((use-dialog-box nil)
163+
(type (if type (intern type) value-type)))
163164
(cl-case type
164165
(file (read-file-name label nil default))
165166
(text (read-string label default))
@@ -185,6 +186,12 @@
185186
unless value
186187
do (setq parameters (plist-put parameters key
187188
(plist-get input-vars key))))
189+
(cl-loop for (key value) on input-vars by #'cddr
190+
do (message "key:%s value:%s input:%s"
191+
key value (plist-get input-vars key))
192+
unless (plist-member parameters key)
193+
do (setq parameters (plist-put parameters key
194+
(plist-get input-vars key))))
188195
parameters)
189196

190197
(defun phpactor--command-argments-1 (key)
@@ -194,6 +201,7 @@
194201
(point-min) (point-max)))
195202
(:path buffer-file-name)
196203
(:offset (1- (point)))
204+
(:current_path buffer-file-name)
197205
(t (error "`%s' is unknown argument" key))))
198206

199207
(defun phpactor--command-argments (&rest arg-keys)
@@ -316,6 +324,13 @@
316324
(let ((arguments (phpactor--command-argments :source :path)))
317325
(apply #'phpactor-action-dispatch (phpactor--rpc "transform" arguments))))
318326

327+
;;;###autoload
328+
(defun phpactor-context-menu ()
329+
"Execute Phpactor PRC context_menu command."
330+
(interactive)
331+
(let ((arguments (phpactor--command-argments :source :offset :current_path)))
332+
(apply #'phpactor-action-dispatch (phpactor--rpc "context_menu" arguments))))
333+
319334
;;;###autoload
320335
(defun phpactor-navigate ()
321336
"Execute Phpactor RPC navigate command."

0 commit comments

Comments
 (0)