I am using Emacs with Projectile (besides other packages) for MySQL development.
Here's a couple of little tweaks to save a few keystrokes here and there:
- Visit (which in Emacs parlance means open) the MTR test file, by its MTR name
instead of file path:
;; This is a not a MySQL-specific implementation of `projectile-find-test-file'.
;; That function is meant for jumping from a source file to its test file.
;; TODO(laurynas): this is not an exhaustive implementation for all locations
;; test files can reside. Add them as the need arises.
(defun my-visit-mtr-test ()
"Input MySQL MTR test name and visit it."
(interactive)
(let* ((input (read-string "MySQL MTR test name: "))
;; TODO(laurynas): error checking
(parts (split-string input "\\."))
(suite-name (car parts))
(test-in-suite (concat "t/" (cadr parts) ".test"))
(test-root (concat (projectile-project-root) "mysql-test/"))
(file-path (if (string= suite-name "main")
(concat test-root test-in-suite)
(concat test-root "suite/" suite-name "/"
test-in-suite))))
(find-file file-path)))
(define-key projectile-command-map "M" #'my-visit-mtr-test)
The last line binds this command to M in the Projectile command map, so if your
Projectile keybinding prefix is C-c p
(C
is Ctrl in case non-Emacs users are
still reading), you can do C-c p M
to invoke it.
- Register .test and .result files as "other file types" for each other. This way
projectile-find-other-file
(at e.g. C-c p a
) can be used for quick jumping
between tests and their results:
(add-to-list 'projectile-other-file-alist '("test" "result"))
(add-to-list 'projectile-other-file-alist '("result" "test"))
If I think of more utilities, I'll try not to forget to update this post.