1

I have Vertico configured in my Emacs 28.2 running on Linux, along with Orderless as follows:

;; Enable vertico:
(use-package vertico
  :ensure t
  :init
  (vertico-mode))

;; Enable orderless:
(use-package orderless
    :ensure t
    :custom
    (completion-styles '(orderless basic))
    (completion-category-overrides '((file (styles orderless basic partial-completion)))))

That configuration works great for find-files. But when I use M-x shell and then try to use TAB to complete files, I get the standard *Completions* window and not the Vertico window in the minibuffer as I do when using find-files. This is not desired because in order to have Emacs complete to one of them, I would then have to use the mouse (causing RSI overtime). So, what do I need to change so that the list pops up and I can type in random other strings, in an orderless manner, to narrow down the candidates, also being able to use up and down arrow keys to select the candidates manually when need be?

Example:

I created a demo directory inside /tmp/foo/ and populated it with a bunch of nonsense files that all have "xyz" in the filename. I then open up a shell via M-x shell and type:

ls /tmp/foo/xyz

and then after the "z", I type TAB. I then see the completions buffer:

Click on a completion to select it.
In this buffer, type RET to select the completion near point.

Possible completions are:
the_xyz     xyz_1   xyz_10  xyz_100     xyz_11  xyz_12  xyz_13  xyz_14  xyz_15  xyz_16
xyz_17  xyz_18  xyz_19  xyz_2   xyz_20  xyz_21  xyz_22  xyz_23  xyz_24  xyz_25
xyz_26  xyz_27  xyz_28  xyz_29  xyz_3   xyz_30  xyz_31  xyz_32  xyz_33  xyz_34
xyz_35  xyz_36  xyz_37  xyz_38  xyz_39  xyz_4   xyz_40  xyz_41  xyz_42  xyz_43
xyz_44  xyz_45  xyz_46  xyz_47  xyz_48  xyz_49  xyz_5   xyz_50  xyz_51  xyz_52
xyz_53  xyz_54  xyz_55  xyz_56  xyz_57  xyz_58  xyz_59  xyz_6   xyz_60  xyz_61
xyz_62  xyz_63  xyz_64  xyz_65  xyz_66  xyz_67  xyz_68  xyz_69  xyz_7   xyz_70
xyz_71  xyz_72  xyz_73  xyz_74  xyz_75  xyz_76  xyz_77  xyz_78  xyz_79  xyz_8
xyz_80  xyz_81  xyz_82  xyz_83  xyz_84  xyz_85  xyz_86  xyz_87  xyz_88  xyz_89
xyz_9   xyz_90  xyz_91  xyz_92  xyz_93  xyz_94  xyz_95  xyz_96  xyz_97  xyz_98
xyz_99  xyz_then_something

The "xyz" is highlighted in blue as expected, but it is not "vertical" like the Vertico package offers.

I read through all of the Vertico docs and the wiki and could not discover how to get Vertico to play fair in the shell buffer mode.

1 Answer 1

3

C-h k <tab> gives

TAB (translated from <tab>) runs the command completion-at-point (found in shell-mode-map), which is an interactive compiled-function in minibuffer.el.

It is bound to TAB.


(completion-at-point)

Perform completion on the text around point. The completion method is determined by completion-at-point-functions.

Probably introduced at or before Emacs version 23.2.

which suggests what you see below.


Vertico`: 3.2 Completion-at-point and completion-in-region

The tab completion command completion-at-point command is usually bound to M-TAB or TAB. Tab completion is also used in the minibuffer by M-: (eval-expression). In case you want to use Vertico to show the completion candidates of completion-at-point and completion-in-region, you can use the function consult-completion-in-region provided by the Consult package.

;; Use `consult-completion-in-region' if Vertico is enabled.
;; Otherwise use the default `completion--in-region' function.
(setq completion-in-region-function
      (lambda (&rest args)
        (apply (if vertico-mode
                   #'consult-completion-in-region
                 #'completion--in-region)
               args)))

You may also want to look into Corfu: COmpletion in Region FUnction package, which provides a minimal completion system for completion-in-region in a child frame popup. Corfu is a narrowly focused package and developed in the same spirit as Vertico. You can even use Corfu in the minibuffer.

1
  • Thank you! I verified that as working right out of the box. I missed that completely as I was looking for something involving shell mode, and github.com/minad/… does not mention specifically shell mode.
    – bgoodr
    Commented Mar 30 at 1:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.