GNU bug report logs - #62263
28.1; Feature Request: Favorites variable support for minibuffers

Previous Next

Package: emacs;

Reported by: omer.kasapoglu <at> boun.edu.tr

Date: Sat, 18 Mar 2023 16:38:02 UTC

Severity: wishlist

Found in version 28.1

To reply to this bug, email your comments to 62263 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#62263; Package emacs. (Sat, 18 Mar 2023 16:38:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to omer.kasapoglu <at> boun.edu.tr:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 18 Mar 2023 16:38:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: omer.kasapoglu <at> boun.edu.tr
To: bug-gnu-emacs <at> gnu.org
Subject: 28.1; Feature Request: Favorites variable support for minibuffers
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.






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62263; Package emacs. (Wed, 22 Mar 2023 17:53:02 GMT) Full text and rfc822 format available.

Message #8 received at 62263 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: omer.kasapoglu <at> boun.edu.tr
Cc: 62263 <at> debbugs.gnu.org
Subject: Re: bug#62263: 28.1; Feature Request: Favorites variable support
 for minibuffers
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.




This bug report was last modified 1 year and 7 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.