1

When I do M-x bury, my completion setup (I use fido-mode, along with vertico and marginalia), produces these results:

1/95   M-x bury
rmail-bury ...
bury-buffer ...
unbury-buffer ...
(etc etc etc)

I don't use rmail, and what I want is bury-buffer. But the completion always finds the rmail one first.

I've tried fiddling a bit with completion styles but the sorting always puts rmail-bury first.

How can I get bury-buffer to "win" over rmail-bury? I want something that either changes the sort order, or outright suppresses the rmail result, or something so that I can type M-x bury and have the first result be bury-buffer?

Drew
  • 77,472
  • 10
  • 114
  • 243
Dan Drake
  • 615
  • 3
  • 18

2 Answers2

2

Setting completion-styles to (basic) should make b TAB use only prefix completion, which eliminates anything doesn't start with b.


If you use Icicles then you have lots of possibilities for dealing with this kind of annoyance/problem, and without tying your hands for other situations where you don't want to be limited to, say, just prefix completion.

With Icicles:

  1. TAB gives you vanilla Emacs completion, so it respects completion-styles. But you also switch to other sets of completion styles, cycling among them on the fly, using C-M-(.

  2. You also have multiple completion methods, which go beyond completion styles. And you can, likewise, switch to other methods on the fly (using C-( or M-(, depending on the group of methods you want to cycle).

  3. You can set the completion method (which, if vanilla, means you can also set the completion-styles) to use for a particular command only. For example, for your bury-buffer situation, you could dedicate a particular completion method just for the command bound to M-x.

  4. You can use regexp completion (which includes substring completion) or various kinds of "flex/scatter" or "fuzzy" completion, to quickly match a pattern.

  5. You can match multiple patterns (of any kinds), to quickly narrow the match set. This is Progressive Completion.

  6. You can selectively remove individual completion candidates or all candidates matching a pattern -- chipping away the non-elephant.

  7. You can sort the current completion matches, on the fly, in various ways, including sort orders that you can define yourself.

And there are other Icicles features that you can put to use to simplify getting to bury-buffer without being bothered by noise.

Drew
  • 77,472
  • 10
  • 114
  • 243
  • Thanks -- I'll look into icicles. I'm always nervous about "just start using this big complex framework, which is just one of many similar frameworks"; sometimes enabling something like somehow makes many things work slightly differently, and I may not want to put in all the effort into learning a new framework thingy. But, as they say, configuring emacs is not so much a task as it is a lifestyle choice. I'll see about choosing the "try out icicles" lifestyle. :) – Dan Drake Jul 27 '23 at 13:15
  • Understood. ;-) – Drew Jul 27 '23 at 14:40
0

For what it's worth, here's an extremely effective, but very bad answer: just fiddle with the name of the rmail function.

I edited rmail.el and changed

(defun rmail-bury ()

to

(defun rmail-xbxury ()

which very effectively defeats any substring or similar completion matching when I do M-x bury.

(If you have compiled .elc files, you'll need to recompile, or delete that, or something, but I'm doing this on Windows in emacs 28 and there's no rmail.elc with the rmail-bury defun.)

Now, of course, this breaks rmail -- but since I never use that, I don't mind.

In terms of elegance and good coding practice, this is, of course, awful -- but in terms of simplicity and effectiveness, it's excellent...

Dan Drake
  • 615
  • 3
  • 18