Skip to content

Commit

Permalink
store popup arguments locally in output buffer for reuse
Browse files Browse the repository at this point in the history
closes #3.
  • Loading branch information
wbolster committed Feb 27, 2018
1 parent 0ed385f commit 948a589
Showing 1 changed file with 28 additions and 21 deletions.
49 changes: 28 additions & 21 deletions python-pytest.el
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ With a prefix ARG, allow editing."
(user-error "No previous pytest run for this project"))
(python-pytest--run-command
:command command
:popup-arguments python-pytest-arguments
:edit current-prefix-arg)))


Expand All @@ -293,24 +294,26 @@ With a prefix ARG, allow editing."

(cl-defun python-pytest--run (&key args file func edit)
"Run pytest for the given arguments."
(setq args (python-pytest--transform-arguments args))
(when (and file (file-name-absolute-p file))
(setq file (python-pytest--relative-file-name file)))
(when func
(setq func (s-replace "." "::" func)))
(let ((command)
(thing (cond
((and file func) (format "%s::%s" file func))
(file file))))
(when thing
(setq args (-snoc args (python-pytest--shell-quote thing))))
(setq args (cons python-pytest-executable args)
command (s-join " " args))
(python-pytest--run-command
:command command
:edit edit)))

(cl-defun python-pytest--run-command (&key command edit)
(let ((popup-arguments args))
(setq args (python-pytest--transform-arguments args))
(when (and file (file-name-absolute-p file))
(setq file (python-pytest--relative-file-name file)))
(when func
(setq func (s-replace "." "::" func)))
(let ((command)
(thing (cond
((and file func) (format "%s::%s" file func))
(file file))))
(when thing
(setq args (-snoc args (python-pytest--shell-quote thing))))
(setq args (cons python-pytest-executable args)
command (s-join " " args))
(python-pytest--run-command
:command command
:popup-arguments popup-arguments
:edit edit))))

(cl-defun python-pytest--run-command (&key command popup-arguments edit)
"Run a pytest command line."
(let* ((default-directory (python-pytest--project-root)))
(when python-pytest-confirm
Expand All @@ -324,9 +327,11 @@ With a prefix ARG, allow editing."
(setq python-pytest--history (-uniq python-pytest--history))
(puthash (python-pytest--project-root) command
python-pytest--project-last-command)
(python-pytest-run-as-comint command)))
(python-pytest-run-as-comint
:command command
:popup-arguments popup-arguments)))

(defun python-pytest-run-as-comint (command)
(cl-defun python-pytest-run-as-comint (&key command popup-arguments)
"Run a pytest comint session for COMMAND."
(let* ((buffer (python-pytest--get-buffer))
(process (get-buffer-process buffer)))
Expand All @@ -340,7 +345,9 @@ With a prefix ARG, allow editing."
(erase-buffer)
(python-pytest-mode)
(insert (format "cwd: %s\ncmd: %s\n\n" default-directory command))
(setq python-pytest--current-command command)
(make-local-variable 'python-pytest-arguments)
(setq python-pytest--current-command command
python-pytest-arguments popup-arguments)
(when python-pytest-pdb-track
(add-hook
'comint-output-filter-functions
Expand Down

0 comments on commit 948a589

Please sign in to comment.