Skip to content

Commit 448bd2f

Browse files
authored
Merge pull request #48 from emacs-php/feature/apply-working-directory
Apply working directory
2 parents 61e4eab + da67cce commit 448bd2f

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

phpactor.el

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,15 @@
114114
(setq phpactor-history-ring (make-ring phpactor-history-size)))
115115
(ring-insert phpactor-history-ring (cons name entry)))
116116

117+
(defun phpactor-config:dump ()
118+
"Execute Phpactor `config:dump' sub command."
119+
(interactive)
120+
(let ((default-directory (phpactor-get-working-dir)))
121+
(funcall
122+
(if (called-interactively-p 'interactive)
123+
#'shell-command
124+
#'shell-command-to-string)
125+
(phpactor--make-command-string "config:dump"))))
117126

118127
;; Phpactor RPC
119128
(defun phpactor--rpc (action arguments)
@@ -124,13 +133,14 @@
124133
(json-object-type 'plist)
125134
(json-array-type 'list)
126135
(output (get-buffer-create "*Phpactor Output*"))
127-
(cwd (phpactor-get-working-dir))
128-
(phpactor-executable (phpactor-find-executable)))
136+
(phpactor-executable (phpactor-find-executable))
137+
;; `default-directory' is a *special variable*
138+
(default-directory (phpactor-get-working-dir)))
129139
(with-current-buffer output (erase-buffer))
130140
(with-current-buffer (get-buffer-create "*Phpactor Input*")
131141
(erase-buffer)
132142
(insert json)
133-
(call-process-region (point-min) (point-max) phpactor-executable nil output nil "rpc" (format "--working-dir=%s" cwd))
143+
(call-process-region (point-min) (point-max) phpactor-executable nil output nil "rpc" (format "--working-dir=%s" default-directory))
134144
(with-current-buffer output
135145
(goto-char (point-min))
136146
(json-read-object)))))

0 commit comments

Comments
 (0)