josior · 2022-05-10 23:23
I usually try to find customize options with `M-x` `customize-apropos`, but when there's no match I have to go through `M-x` customize-apropos and try again.
How can I go back directly to try a new query and skip the part of going through `M-x` customize-apropos and typing something else?
I know I can use something like `M-x M-p RET M-p` but it's still an extra step (or two).
Thanks!
00-11 · 2022-05-11 01:59
Yes, `customize-apropos` is a good command, but it's limited. It doesn't even offer completion.
----
There are no doubt better alternatives out there. One is the Customize apropos commands offered by [Icicles](https://www.emacswiki.org/emacs/Icicles). (Other libraries probably also offer good behavior; dunno.) These are those commands:
* `icicle-customize-apropos`
* `icicle-customize-apropos-faces`
* `icicle-customize-apropos-groups`
* `icicle-customize-apropos-options`
* `icicle-customize-apropos-opts-w-val-satisfying`
* `icicle-customize-apropos-options-of-type`
The first three act similarly, differing only in the kind of user preferences they handle. `icicle-customize-apropos` matches faces, options, and groups. They all do this:
> Customize all loaded user preferences matching `PATTERN`.
>
> When prompted for the `PATTERN`, you can use completion against
preference names - e.g. `S-TAB`. Instead of entering a pattern you
can then just hit `RET` to accept the list of matching preferences.
This lets you see which preferences will be available in the customize
buffer and dynamically change that list.
The last two commands are more particular.
`icicle-customize-apropos-opts-w-val-satisfying` customizes the set of options whose values satisfy a predicate and whose names match a pattern. (You're prompted for the predicate and the pattern.)
`icicle-customize-apropos-options-of-type` can match options by name, defcustom type, or both name and type - it is a [multi-completion](https://www.emacswiki.org/emacs/Icicles_-_Multi-Completions) command.
The pattern used to match the option *name* is a regexp.
The pattern used to match the *type* is either a regexp or a definition acceptable for defcustom `:type`, or the first symbol of such a definition -- for example, `(choice (integer) (regexp))` or `choice`.
In the second case, depending on the prefix arg, the pattern can be matched against (1) the option type or (2) the option type or one of its subtypes. Also depending on the prefix arg, the pattern can match an option if it matches the option *value* instead of the type.
In sum, the prefix arg determines the type-matching behavior, as
follows:
* No prefix arg: The option is defined with a type or subtype that matches the type pattern, which is a *regexp*.
* `C-u`: The option is defined either (1) with a type or subtype that matches the type pattern, which is a *type definition* or its first *symbol*, **or** (2) the option *value is compatible* with such a type.
* Negative: The option is defined with a type that exactly matches (no subtype matches) the type pattern, which is a regexp.
* Positive: Either (1) the option is defined with a type that exactly matches the type pattern, or (2) its current value is compatible with such a type. The type pattern is a type definition or its first symbol.
* Zero: The option is defined with a type or subtype that exactly matches the type pattern, which is a type definition or its first symbol.
* `C-u C-u`: The option is defined with a type that exactly matches the type pattern, which is a type definition or its first symbol.
----
See [Icicles - A Propos d'Apropos](https://www.emacswiki.org/emacs/Icicles_-_A_Propos_d'Apropos).
prismavoid08 · 2022-05-11 02:10
You could try advising the function to prompt for a new argument whenever it throws an error, just put the following in your init.el. It also has the benefit of automatically working for the other customize-apropos functions. Just put the following in your init.el:
(defun my-customize-apropos-advice (func &rest args)
(while (not (ignore-errors (apply func args)))
(setcar args (read-string "Search for symbol (word list or regexp): "))))
(advice-add 'customize-apropos :around 'my-customize-apropos-advice)
Illiamen · 2022-05-11 02:14
In general, you might be interested in the command `repeat-complex-command` (`C-x ESC ESC`): https://www.emacswiki.org/emacs/RepeatingComplexCommand
There are also commands like `vertico-repeat` and `selectrum-repeat`, depending on the completion interface that you use.
josior · 2022-05-11 23:31
Thanks!
I'm not sure on how `repeat-complex-command` should work. When I run this command, it opens the mini buffer with `Redo: (repeat-complex-command 1)` and I'm not sure how I should interact with it.
I use Ivy/Swiper/Counsel, and I couldn't find a equivalent to the ones you suggested.
josior · 2022-05-11 23:32
Thanks!
When running the command now, it just erases my input and simply doesn't run, even if there's a match. Maybe `counsel` is affecting the behavior?
josior · 2022-05-11 23:34
Thanks!
This seems very interesting, and sounds like it would be good to have it as a default. It seems that Icicles is not available on ELPA/MELPA, so I guess I will need to install manually if I want to try it.
Illiamen · 2022-05-12 02:23
For Ivy, I think you are looking for `ivy-resume`. Keep in mind that such commands need to be run via a key binding like `C-c r`. If you try to run them via `M-x`, then they'll just resume the `M-x`.
`repeat-complex-command` shows you what Emacs did after getting your input. You can edit this and run a command again using different arguments. For example:
1. I run `M-x customize-apropos RET aaaaa RET`.
2. Emacs tells me that nothing was found.
3. I press `C-x ESC ESC` to run `repeat-complex-command`.
4. Emacs suggests my previous command in the minibuffer, showing `(customize-apropos '("aaaaaaa") nil)`. I could use `M-p` or `M-n` to see other previous commands.
5. I find the input I gave it ("aaaaa").
6. I edit this expression and replace "aaaaa" with some other argument, such as "net".
7. The minibuffer contents is now `(customize-apropos '("net") nil)`.
8. I press `RET` to make Emacs run this new expression.
9. Emacs shows the matching variables for "net".
`repeat-complex-command` is useful when Emacs asked for more than 1 thing. Commands like `ivy-resume` or `vertico-repeat` are good enough for most things.
00-11 · 2022-05-12 17:00
Correct - download from Emacs Wiki, and put the files in a directory in your `load-path`. See [Icicles - Libraries](https://www.emacswiki.org/emacs/Icicles_-_Libraries).