From 8f4beaaba269c3312c149fcb05414fdb8f7bdcae Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 10 Aug 2022 19:44:55 +0300 Subject: [PATCH] feat(tazjin/emacs): add helper function for navigating tvix tests the upstream Nix test suite uses the pattern of having `.nix` and `.exp` files for input/expected output, and with this shitty function navigating between them is a lot simpler Change-Id: I9d91290057521fe1e1599f69fd6b0f35e1b59960 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6058 Reviewed-by: tazjin Autosubmit: tazjin Tested-by: BuildkiteCI --- users/tazjin/emacs/config/functions.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/users/tazjin/emacs/config/functions.el b/users/tazjin/emacs/config/functions.el index 602809138..e725c23cc 100644 --- a/users/tazjin/emacs/config/functions.el +++ b/users/tazjin/emacs/config/functions.el @@ -340,4 +340,15 @@ the GPG agent correctly." (interactive) (zoxide-open-with nil #'magit-status-setup-buffer)) +(defun toggle-nix-test-and-exp () + "Switch between the .nix and .exp file in a Tvix/Nix test." + (interactive) + (let* ((file (buffer-file-name)) + (other (if (s-suffix? ".nix" file) + (s-replace-regexp ".nix$" ".exp" file) + (if (s-suffix? ".exp" file) + (s-replace-regexp ".exp$" ".nix" file) + (error "Not a .nix/.exp file!"))))) + (find-file other))) + (provide 'functions)