Subject: Re: bug#62263: 28.1; Feature Request: Favorites variable support for minibuffers

From: Juri Linkov <[email-masked]>
Date: Wed, 22 Mar 2023 19:43:12 +0200

> If anyone can provide me with some hack around the history variable
> to emulate those benefits, i would be glad.

One example that you could look at is project--read-file-cpd-relative
where it filters out non-project history items:

         (relname (cl-letf ((history-add-new-input nil)
                            ((symbol-value hist)
                             (mapcan
                              (lambda (s)
                                (and (string-prefix-p abbr-cpd s)
                                     (not (eq abbr-cpd-length (length s)))
                                     (list (substring s abbr-cpd-length))))
                              (symbol-value hist))))
                    (project--completing-read-strict prompt
                                                     new-collection
                                                     predicate
                                                     hist mb-default)))

The same way you could filter out non-favorites from the currently
active history list symbol from minibuffer-history-variable for your
commands next-favorite-element and previous-favorite-element, or
in an advice-add around next-history-element/previous-history-element.