Function: projectile-register-project-type
projectile-register-project-type is a byte-compiled function defined
in projectile.el.
Signature
(projectile-register-project-type PROJECT-TYPE MARKER-FILES &key PROJECT-FILE COMPILATION-DIR CONFIGURE COMPILE INSTALL PACKAGE TEST RUN TEST-SUFFIX TEST-PREFIX SRC-DIR TEST-DIR SRC-EXTENSION TEST-EXTENSION RELATED-FILES-FN FILE-KINDS TASKS)
Documentation
Register a project type with projectile.
A project type is defined by PROJECT-TYPE, a set of MARKER-FILES, and optional keyword arguments.
MARKER-FILES is either a list of files or a predicate function. When it
is a list, ALL of the listed files must be present in the project root for
the type to match (logical AND) - so a single-file marker like ("Foo")
is the common case. A list element may itself be an alternatives clause
of the form (:any FILE...), which is satisfied when any one of its FILEs
is present, so ((:any "build.gradle" "build.gradle.kts")) matches a
project with either of them. For anything more involved, don't pass a
list; use a predicate function instead. The predicate is called with the
project root as its single argument and should return non-nil when the
project is of this type.
The optional keyword arguments are:
PROJECT-FILE the main project file in the root project directory. It may be a
single file or a list of possible files. When omitted it
defaults to the first marker file, or to all the alternatives
of the first marker clause. Pass the symbol none
to opt out, so the type is detected but contributes no
project-root marker (e.g. when its marker also appears
outside real projects).
COMPILATION-DIR the directory to run the tests- and compilations in,
CONFIGURE which specifies a command that configures the project
%s in the command will be substituted with (projectile-project-root)
before the command is run,
COMPILE which specifies a command that builds the project,
INSTALL which specifies a command to install the project.
PACKAGE which specifies a command to package the project.
TEST which specifies a command that tests the project,
RUN which specifies a command that runs the project,
TEST-SUFFIX which specifies test file suffix, and
TEST-PREFIX which specifies test file prefix.
SRC-DIR which specifies the path to the source relative to the project root.
TEST-DIR which specifies the path to the tests relative to the project root.
SRC-EXTENSION which specifies the file extension implementation files use,
when it differs from the one their tests use.
TEST-EXTENSION which specifies the file extension test files use, when it
differs from the implementation's (Elixir tests are scripts: foo.ex\=
is tested by foo_test.exs\=).
RELATED-FILES-FN which specifies a custom function to find the related
files such as test/impl/other files as below:
CUSTOM-FUNCTION accepts FILE as relative path from the project root and
returns a plist containing :test, :impl or :other as key and the
relative path/paths or predicate as value. PREDICATE accepts a
relative path as the input.
FILE-KINDS an alist of (KIND . SPEC) declaratively describing the kinds of
files the project type has (e.g. Rails models, controllers and views),
used by projectile-find-file-of-kind and
projectile-toggle-related-file. KIND is a keyword and SPEC is a plist;
see projectile--file-kinds-related-files-fn for the supported
properties. When both FILE-KINDS and RELATED-FILES-FN are set they are
combined, so declarative and hand-written relations coexist.
TASKS an alist of named tasks of the form (TASK-NAME . COMMAND) run via
projectile-run-task; see projectile-tasks for the exact shape.
All command strings (CONFIGURE, COMPILE, INSTALL, PACKAGE, TEST, RUN,
and TASKS commands) support %p as a placeholder that will be replaced
with the project name at execution time.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(cl-defun projectile-register-project-type
(project-type marker-files &key project-file compilation-dir configure compile install package test run test-suffix test-prefix src-dir test-dir src-extension test-extension related-files-fn file-kinds tasks)
"Register a project type with projectile.
A project type is defined by PROJECT-TYPE, a set of MARKER-FILES,
and optional keyword arguments.
MARKER-FILES is either a list of files or a predicate function. When it
is a list, ALL of the listed files must be present in the project root for
the type to match (logical AND) - so a single-file marker like `(\"Foo\")'
is the common case. A list element may itself be an alternatives clause
of the form (:any FILE...), which is satisfied when any one of its FILEs
is present, so `((:any \"build.gradle\" \"build.gradle.kts\"))' matches a
project with either of them. For anything more involved, don't pass a
list; use a predicate function instead. The predicate is called with the
project root as its single argument and should return non-nil when the
project is of this type.
The optional keyword arguments are:
PROJECT-FILE the main project file in the root project directory. It may be a
single file or a list of possible files. When omitted it
defaults to the first marker file, or to all the alternatives
of the first marker clause. Pass the symbol `none'
to opt out, so the type is detected but contributes no
project-root marker (e.g. when its marker also appears
outside real projects).
COMPILATION-DIR the directory to run the tests- and compilations in,
CONFIGURE which specifies a command that configures the project
`%s' in the command will be substituted with (projectile-project-root)
before the command is run,
COMPILE which specifies a command that builds the project,
INSTALL which specifies a command to install the project.
PACKAGE which specifies a command to package the project.
TEST which specifies a command that tests the project,
RUN which specifies a command that runs the project,
TEST-SUFFIX which specifies test file suffix, and
TEST-PREFIX which specifies test file prefix.
SRC-DIR which specifies the path to the source relative to the project root.
TEST-DIR which specifies the path to the tests relative to the project root.
SRC-EXTENSION which specifies the file extension implementation files use,
when it differs from the one their tests use.
TEST-EXTENSION which specifies the file extension test files use, when it
differs from the implementation's (Elixir tests are scripts: `foo.ex\\='
is tested by `foo_test.exs\\=').
RELATED-FILES-FN which specifies a custom function to find the related
files such as test/impl/other files as below:
CUSTOM-FUNCTION accepts FILE as relative path from the project root and
returns a plist containing :test, :impl or :other as key and the
relative path/paths or predicate as value. PREDICATE accepts a
relative path as the input.
FILE-KINDS an alist of (KIND . SPEC) declaratively describing the kinds of
files the project type has (e.g. Rails models, controllers and views),
used by `projectile-find-file-of-kind' and
`projectile-toggle-related-file'. KIND is a keyword and SPEC is a plist;
see `projectile--file-kinds-related-files-fn' for the supported
properties. When both FILE-KINDS and RELATED-FILES-FN are set they are
combined, so declarative and hand-written relations coexist.
TASKS an alist of named tasks of the form (TASK-NAME . COMMAND) run via
`projectile-run-task'; see `projectile-tasks' for the exact shape.
All command strings (CONFIGURE, COMPILE, INSTALL, PACKAGE, TEST, RUN,
and TASKS commands) support `%p' as a placeholder that will be replaced
with the project name at execution time."
(setq projectile-project-types
(cons `(,project-type .
,(projectile--build-project-plist
marker-files
:project-file project-file
:compilation-dir compilation-dir
:configure configure
:compile compile
:install install
:package package
:test test
:run run
:test-suffix test-suffix
:test-prefix test-prefix
:src-dir src-dir
:test-dir test-dir
:src-extension src-extension
:test-extension test-extension
:related-files-fn related-files-fn
:file-kinds file-kinds
:tasks tasks))
projectile-project-types)))