underconstructions · 2022-11-17 00:00
I want something like a mapped information structure; I want to be able to do something like `M-x (the-whatever-command-that-will-do-the-job)` and then insert a key, and then information about that key. And be able to gather it easily with ivy completion for example and copy it to clipboard.
What I can use for this?
takeonrules · 2022-11-17 00:41
So `M-x (the-whatever-command-that-will-do-the-job)` prompts for a key and details; I assume adding to a dictionary or plist. Then you want to see what you've assigned to the key or keys?
Wondering if there's inspiration in Ivy's interaction with the register?
arthurno1 · 2022-11-17 05:36
You can use a set of key-value pairs. Depending on how much information there will be you might prefer a hash-map if you have a lot, or a list, either [alist \(associative list\)](https://www.gnu.org/software/emacs/manual/html_node/elisp/Association-Lists.html) or a [plist \(property list\)](https://www.gnu.org/software/emacs/manual/html_node/elisp/Property-Lists.html). The part about [using lists as sets ](https://www.gnu.org/software/emacs/manual/html_node/elisp/Sets-And-Lists.html) is quite useful too. If you expect more data than few tens or hundreds of items, than a [hashmap might be more efficient](https://www.gnu.org/software/emacs/manual/html_node/elisp/Hash-Tables.html).
I have no idea how ivy works, but if you are using [the built-in completing read](https://www.gnu.org/software/emacs/manual/html_node/elisp/Completion.html) to choose an item in your collection, which you probably should, then an alist or a hashmap might be a good choice.
To learn how to insert strings interactively from minibuffer into your collection, read [the parts about minibuffer in the manual](https://www.gnu.org/software/emacs/manual/html_node/elisp/Text-from-Minibuffer.html). You can use '[add-to-list](https://www.gnu.org/software/emacs/manual/html_node/elisp/List-Variables.html)' to ensure you are not inserting duplicates if you are using lists.