Skip to content

Commit

Permalink
Implement phpactor-action-collection and phpactor-action-close-file
Browse files Browse the repository at this point in the history
phpactor sometimes need to run a sequence of actions, which this
commit adds support for. In order to support class renaming,
phpactor-action-close-file is also added.

resolves #36 (class renaming)
  • Loading branch information
kermorgant committed Aug 6, 2018
1 parent 17819d6 commit c2f4c3d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions phpactor.el
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@
(let ((use-dialog-box nil)
(type (if type (intern type) value-type)))
(cl-case type
(confirm (if (y-or-n-p label) t
(error "Action cancelled")))
(file (read-file-name label nil default))
(text (read-string label default))
(choice (completing-read label
Expand Down Expand Up @@ -257,6 +259,13 @@
(view-mode 1))
(pop-to-buffer buffer)))

(cl-defun phpactor-action-collection (&key actions)
"Executes a collection of actions."
(mapc
(lambda (action)
(apply #'phpactor-action-dispatch (list :action (plist-get action :name) :parameters (plist-get action :parameters))))
actions))

(cl-defun phpactor-action-open-file (&key path offset)
"Open file from Phpactor."
(unless (and path offset)
Expand All @@ -270,6 +279,10 @@
(find-file path)
(goto-char (1+ offset)))

(cl-defun phpactor-action-close-file (&key path)
"Close file from Phpactor."
(kill-buffer (find-file-noselect path t)))

;; this function was adapted from go-mode
(defun phpactor--goto-line (line)
"Goto line LINE."
Expand Down

0 comments on commit c2f4c3d

Please sign in to comment.