Add function to find spec file given naming convention in HC

This commit is contained in:
Frederik Hanghøj Iversen 2020-02-11 09:51:54 +01:00
parent f263264a77
commit 42f9790570

13
zdi.el
View file

@ -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