Function: projectile-update-project-type
projectile-update-project-type is a byte-compiled function defined in
projectile.el.
Signature
(projectile-update-project-type PROJECT-TYPE &key PRECEDENCE (MARKER-FILES nil MARKER-FILES-SPECIFIED) (PROJECT-FILE nil PROJECT-FILE-SPECIFIED) (COMPILATION-DIR nil COMPILATION-DIR-SPECIFIED) (CONFIGURE nil CONFIGURE-SPECIFIED) (COMPILE nil COMPILE-SPECIFIED) (INSTALL nil INSTALL-SPECIFIED) (PACKAGE nil PACKAGE-SPECIFIED) (TEST nil TEST-SPECIFIED) (RUN nil RUN-SPECIFIED) (TEST-SUFFIX nil TEST-SUFFIX-SPECIFIED) (TEST-PREFIX nil TEST-PREFIX-SPECIFIED) (SRC-DIR nil SRC-DIR-SPECIFIED) (TEST-DIR nil TEST-DIR-SPECIFIED) (RELATED-FILES-FN nil RELATED-FILES-FN-SPECIFIED))
Documentation
Update an existing projectile project type.
Passed items will override existing values for the project type given
by PROJECT-TYPE. nil can be used to remove a project type attribute. Raise
an error if PROJECT-TYPE is not already registered with projectile. This
function may also take the keyword argument PRECEDENCE which when set to ‘high’
will make projectile prioritise this project type over other clashing project
types, and a value of ‘low’ will make projectile prefer (all) other project
types by default. Otherwise, the arguments to this function are as for
projectile-register-project-type:
A project type is defined by PROJECT-TYPE, a set of MARKER-FILES,
and optional keyword arguments:
MARKER-FILES a set of indicator files for PROJECT-TYPE.
PROJECT-FILE the main project file in the root project directory.
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.
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.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260310.858/projectile.el
(cl-defun projectile-update-project-type
(project-type
&key precedence
(marker-files nil marker-files-specified)
(project-file nil project-file-specified)
(compilation-dir nil compilation-dir-specified)
(configure nil configure-specified)
(compile nil compile-specified)
(install nil install-specified)
(package nil package-specified)
(test nil test-specified)
(run nil run-specified)
(test-suffix nil test-suffix-specified)
(test-prefix nil test-prefix-specified)
(src-dir nil src-dir-specified)
(test-dir nil test-dir-specified)
(related-files-fn nil related-files-fn-specified))
"Update an existing projectile project type.
Passed items will override existing values for the project type given
by PROJECT-TYPE. nil can be used to remove a project type attribute. Raise
an error if PROJECT-TYPE is not already registered with projectile. This
function may also take the keyword argument PRECEDENCE which when set to ‘high’
will make projectile prioritise this project type over other clashing project
types, and a value of ‘low’ will make projectile prefer (all) other project
types by default. Otherwise, the arguments to this function are as for
`projectile-register-project-type':
A project type is defined by PROJECT-TYPE, a set of MARKER-FILES,
and optional keyword arguments:
MARKER-FILES a set of indicator files for PROJECT-TYPE.
PROJECT-FILE the main project file in the root project directory.
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.
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."
(let* ((existing-project-plist
(or (seq-find
(lambda (p) (eq project-type (car p))) projectile-project-types)
(error "No existing project found for: %s" project-type)))
(new-plist
(append
(when marker-files-specified `(marker-files ,marker-files))
(when project-file-specified `(project-file ,project-file))
(when compilation-dir-specified `(compilation-dir ,compilation-dir))
(when configure-specified `(configure-command ,configure))
(when compile-specified `(compile-command ,compile))
(when test-specified `(test-command ,test))
(when install-specified `(install-command ,install))
(when package-specified `(package-command ,package))
(when run-specified `(run-command ,run))
(when test-suffix-specified `(test-suffix ,test-suffix))
(when test-prefix-specified `(test-prefix ,test-prefix))
(when src-dir-specified `(src-dir ,src-dir))
(when test-dir-specified `(test-dir ,test-dir))
(when related-files-fn-specified
`(related-files-fn ,related-files-fn))))
(merged-plist
(projectile--combine-plists
(cdr existing-project-plist) new-plist))
(project-type-elt (cons project-type merged-plist)))
(cl-flet* ((project-filter (p) (eq project-type (car p)))
(project-map (p) (if (project-filter p) project-type-elt p)))
(setq projectile-project-types
(if precedence
(let ((filtered-types
(seq-remove #'project-filter projectile-project-types)))
(setq projectile-project-type-cache (make-hash-table :test 'equal))
(cond ((eq precedence 'high)
(cons project-type-elt filtered-types))
((eq precedence 'low)
(append filtered-types (list project-type-elt)))
(t (error "Precedence must be one of '(high low)"))))
(mapcar #'project-map projectile-project-types))))))