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

From: [email-masked]
Date: Sat, 18 Mar 2023 15:52:58 +0300

We know that there is many history variables for emacs.
Those provide us with the ability to quickly rerun last
entries from minibuffers.

Some examples to those history variables:

extended-command-history : used from the command execute-extended-command
minibuffer-history       : default history variable for minibuffers
command-history          : used from the command repeat-matching-complex-command

When minibuffers initialized from a command, it sets the variable
minibuffer-history-variable to the related history variable.

Yes savehist-mode is very good and minibuffer histories are essential
for my emacs usage. But there is a thing I want. I want to save
some of those history values permanently in a super accessible way.
I will call those favorites and favorite variables.

I want similar commands for minibuffer histories to exist for also the
favorites variables 

next-history-element      -->  next-favorite-element
previous-history-element  -->  previous-favorite-element

As of emacs 29, there is also
minibuffer-complete-history C-x <up> --> minibuffer-complete-favorites

One big problem for creating those favorites variables is it is
a bit complicated. There is many history variables and all those
are defined from many many libraries.

Making duplicates of all those variables named favorites variables
is probably not the approach we should take.

Could there be any work around from the history variables?
Can we attach those favorites data into those history variables
and access them later from there?

I can't see the internals cleary, but i want these use-cases:

Saving some history elements to this favorites variable in minibuffers
with only one key press.

An interface that probably will be named minibuffer-complete-favorites
to access all those elements from the comfort of my minibuffer.

Maybe a next-history-element and previous-history-element alternatives
for quickly accessing last favorite command. 

If we could implement such a functionality, i think many
current emacs functions will be able to serve us in greater ways

There is some examples to those.

|                                     | with history variable                  | favorites variable                         |
|                                     |                                        |                                            |
| find-file                           | for accessing last visited files       | for accessing favorite files               |
| dired                               | for accessing last visited directories | for accessing favorite directories         |
| execute-extended-command            | for running last run commands          | for accessing favorite commands            |
| execute-extended-command-for-buffer | for running last major mode commands   | for accessing favorite major mode commands |
| eval-expression                     | for evaluating last expression         | for evaluating saved expressions           |
| customize-set-value                 | for changing last changed  variables   | for changing favorite variables            |
|                                     |                                        |                                            |
| ag rg grep locate find              | rerun last search                      | rerun your favorite searches               |
|                                     |                                        |                                            |
| shell-command                       | rerun last shell commands              | rerun favorite shell commands              |
| async-shell-command                 | rerun last shell commands              | rerun favorite shell commands              |
| shell-command-on-region             | rerun last shell commands on region    | rerun favorite shell commands on region    |
|                                     |                                        |                                            |
|                                     |                                        |                                            |
| load-theme                          | reload last loaded themes              | reload your favorite themes                |
| find-library                        | find last visited libraries            | visit your favorite libraries              |
| load-library                        | load last loaded libraries             | load your favorite libraries               |
|                                     |                                        |                                            |
| describe-function                   | describe last looked up functions      | access favorite functions documentations   |
| describe-variable                   | describe last looked up variables      | access favorite variables  documentations  |
|                                     |                                        |                                            |

find-file with favorites variables will be a simpler alternative to bookmark-jump.

eval-expression with favorites variables could be an alternative to repeat-complex-command.
Also eval-expression with favorites variables can run your favorite snippets of codes on demand. 

There is many benefits to using such a favorites functionality.

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