Function: projectile--get-command-history

projectile--get-command-history is a byte-compiled function defined in projectile.el.

Signature

(projectile--get-command-history PROJECT-ROOT &optional COMMAND-TYPE)

Documentation

Return the command history ring for PROJECT-ROOT.

With COMMAND-TYPE non-nil (one of the lifecycle command type symbols, e.g. compile or test, or a (task . TASK-NAME) cons for named tasks) return the history specific to that command type, so histories of different types don't bleed into each other's prompts. With COMMAND-TYPE nil return the combined history, which is what projectile-repeat-last-command reads.

Which history that is depends on projectile--command-history-key - by default the repository's rather than this one checkout's.

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile--get-command-history (project-root &optional command-type)
  "Return the command history ring for PROJECT-ROOT.

With COMMAND-TYPE non-nil (one of the lifecycle command type
symbols, e.g. `compile' or `test', or a (task . TASK-NAME) cons
for named tasks) return the history specific to that command
type, so histories of different types don't bleed into each
other's prompts.  With COMMAND-TYPE nil return the combined history,
which is what `projectile-repeat-last-command' reads.

Which history that is depends on `projectile--command-history-key' - by
default the repository's rather than this one checkout's."
  (let* ((root-key (if command-type (cons project-root command-type) project-root))
         (key (if command-type
                  ;; The per-type histories are the ones you browse at a
                  ;; prompt, so sharing them is all upside: pressing M-p in
                  ;; a fresh worktree offers the commands this project is
                  ;; actually built with.
                  (cons (projectile--command-history-key project-root) command-type)
                ;; The combined history stays this checkout's own.
                ;; `projectile-repeat-last-command' replays its most recent
                ;; entry without asking, and a command typed in another
                ;; checkout can carry absolute paths back into it - being
                ;; handed somebody else's build unasked is no fun.
                project-root)))
    (or (gethash key projectile-project-command-history)
        ;; The per-type histories used to be keyed by root, and they're
        ;; persisted, so an upgrade would otherwise walk into a project you
        ;; have been building for years with nothing in hand.  Adopt this
        ;; root's history as the repository's instead.
        (unless (equal key root-key)
          (when-let* ((inherited (gethash root-key projectile-project-command-history)))
            (remhash root-key projectile-project-command-history)
            (puthash key inherited projectile-project-command-history)))
        (puthash key
                 (make-ring 16)
                 projectile-project-command-history))))