Compare commits

...

3 Commits

Author SHA1 Message Date
Jeremy Dormitzer
baf34a00e9 Add pytest run-command recipe 2021-02-02 10:32:08 -05:00
Jeremy Dormitzer
8ba027565b Define run-command project vars in :init not :config 2021-02-02 10:31:53 -05:00
Jeremy Dormitzer
af3b0669c7 Add keybinding to bury shell-command buffers 2021-02-02 10:30:28 -05:00

View File

@ -1740,6 +1740,7 @@ A function to kill all buffers except the current one from [[https://www.emacswi
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(leader-def-key "!" 'shell-command) (leader-def-key "!" 'shell-command)
(leader-def-key "|" 'shell-command-on-region) (leader-def-key "|" 'shell-command-on-region)
(general-def 'normal shell-mode-map "q" #'bury-buffer)
#+END_SRC #+END_SRC
** Toggles ** Toggles
@ -6512,6 +6513,11 @@ current buffer:
(use-package run-command (use-package run-command
:straight (run-command :host github :repo "bard/emacs-run-command" :straight (run-command :host github :repo "bard/emacs-run-command"
:fork (:host github :repo "jdormit/emacs-run-command" :branch "master")) :fork (:host github :repo "jdormit/emacs-run-command" :branch "master"))
:init
(defvar-local run-command-local-commands nil)
(put 'run-command-local-commands 'safe-local-variable (lambda (_) t))
(defvar-local run-command-project-local-commands nil)
(put 'run-command-project-local-commands 'safe-local-variable (lambda (_) t))
:config :config
(defun run-command-recipe-terraform () (defun run-command-recipe-terraform ()
(when (directory-files default-directory (when (directory-files default-directory
@ -6529,9 +6535,6 @@ current buffer:
(list :command-name "destroy" (list :command-name "destroy"
:command-line "terraform destroy")))) :command-line "terraform destroy"))))
(defvar-local run-command-local-commands nil)
(put 'run-command-local-commands 'safe-local-variable (lambda (_) t))
(defun run-command-recipe-local () (defun run-command-recipe-local ()
(when run-command-local-commands (when run-command-local-commands
(mapcar (cl-function (mapcar (cl-function
@ -6600,9 +6603,6 @@ current buffer:
:working-dir (projectile-compilation-dir)))) :working-dir (projectile-compilation-dir))))
'("test" "run" "compilation" "configure" "install" "package")))) '("test" "run" "compilation" "configure" "install" "package"))))
(defvar-local run-command-project-local-commands nil)
(put 'run-command-project-local-commands 'safe-local-variable (lambda (_) t))
(defun run-command-recipe-project-local () (defun run-command-recipe-project-local ()
(when (and run-command-project-local-commands (projectile-project-root)) (when (and run-command-project-local-commands (projectile-project-root))
(mapcar (cl-function (mapcar (cl-function
@ -6657,6 +6657,29 @@ current buffer:
(list :command-name "edit" (list :command-name "edit"
:command-line (format "sops %s" (buffer-file-name)))))) :command-line (format "sops %s" (buffer-file-name))))))
(defun run-command-recipe-pytest ()
(when (and (derived-mode-p 'python-mode)
(= 0 (call-process "python" nil nil nil "-c" "import pytest")))
(let ((test-file-p (string-match-p "test" (or (buffer-file-name) ""))))
(list
(when (and (projectile-project-root)
(file-exists-p (concat (file-name-as-directory (projectile-project-root))
"tests")))
(list :command-name "test all"
:command-line "pytest tests"
:working-dir (projectile-project-root)))
(when test-file-p
(list :command-name "test this file"
:command-line (format "pytest %s" (buffer-file-name))))
(when (and test-file-p (python-info-current-defun))
(list :command-name "test this function"
:command-line (format "pytest %s::%s"
(buffer-file-name)
(replace-regexp-in-string
"\\."
"::"
(python-info-current-defun)))))))))
:general :general
(leader-map "\"" #'run-command) (leader-map "\"" #'run-command)
(run-command-term-minor-mode-map [remap recompile] #'run-command-term-recompile) (run-command-term-minor-mode-map [remap recompile] #'run-command-term-recompile)
@ -6671,7 +6694,8 @@ current buffer:
run-command-recipe-executables run-command-recipe-executables
run-command-recipe-obelix run-command-recipe-obelix
run-command-recipe-kustomize run-command-recipe-kustomize
run-command-recipe-sops))) run-command-recipe-sops
run-command-recipe-pytest)))
#+end_src #+end_src