Subject: bug#67310: [PATCH] Include the project--list as history when prompting for a project

From: Juri Linkov <[email-masked]>
Date: Mon, 27 Nov 2023 19:10:22 +0200

> +            ;; Iterate in reverse order so project--name-history is in
> +            ;; the correct order.
> +            (dolist (dir (reverse (project-known-project-roots)))
>                ;; we filter out directories that no longer map to a project,
>                ;; since they don't have a clean project-name.
> -              (if-let (proj (project--find-in-directory dir))
> -                  (push (cons (project-name proj) proj) ret)))
> +              (when-let (proj (project--find-in-directory dir))
> +                (let ((name (project-name proj)))
> +                  (push name project--name-history)
> +                  (push (cons name proj) ret))))

This change broke the order of 'C-x p p M-n M-n ...',
so I pushed this fix:

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index f7f057396e1..a81bb63fba4 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1808,7 +1808,7 @@ project-prompt-project-name
                          (name (project-name proj)))
                 (push name project--name-history)
                 (push (cons name proj) ret)))
-            ret))
+            (reverse ret)))
          ;; XXX: Just using this for the category (for the substring
          ;; completion style).
          (table (project--file-completion-table