From 42f97905707f9a387c471d0da3b72dcff0f5e634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederik=20Hangh=C3=B8j=20Iversen?= Date: Tue, 11 Feb 2020 09:51:54 +0100 Subject: [PATCH] Add function to find spec file given naming convention in HC --- zdi.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/zdi.el b/zdi.el index 736a335..22f9fa3 100644 --- a/zdi.el +++ b/zdi.el @@ -21,4 +21,17 @@ (set (make-local-variable 'compile-command) (format zdi-build-command-format (projectile-get-relative-path-buffer)))) +(defun zdi-find-spec-file () + "Go to the spec file corresponding to the currently visited file. + +Depends on file naming convention used in Help Center." + (interactive) + (find-file (zdi-build-spec-path (buffer-file-name)))) + +(defun zdi-build-spec-path (path) + "Guess the location of the spec file corresponding to PATH." + (replace-regexp-in-string + "\\(\\)\\.[^\\.]*$" "_spec" + (replace-regexp-in-string "\\(app\\).*\\'" "spec" path nil nil 1) nil nil 1)) + ;;; zdi.el ends here