all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#62263: 28.1; Feature Request: Favorites variable support for minibuffers
@ 2023-03-18 12:52 omer.kasapoglu
  2023-03-22 17:43 ` Juri Linkov
  0 siblings, 1 reply; 2+ messages in thread
From: omer.kasapoglu @ 2023-03-18 12:52 UTC (permalink / raw)
  To: 62263



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.







^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#62263: 28.1; Feature Request: Favorites variable support for minibuffers
  2023-03-18 12:52 bug#62263: 28.1; Feature Request: Favorites variable support for minibuffers omer.kasapoglu
@ 2023-03-22 17:43 ` Juri Linkov
  0 siblings, 0 replies; 2+ messages in thread
From: Juri Linkov @ 2023-03-22 17:43 UTC (permalink / raw)
  To: omer.kasapoglu; +Cc: 62263

> 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.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-22 17:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-18 12:52 bug#62263: 28.1; Feature Request: Favorites variable support for minibuffers omer.kasapoglu
2023-03-22 17:43 ` Juri Linkov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.