Selectrum: Allow submitting empty string with require-match

Created on 21 Apr 2020  路  4Comments  路  Source: raxod502/selectrum

Currently there is no way to submit an empty string when require-match is t. In default completing read you can submit an empty string which is sometimes used to determine the end of input. As an example see auto-insert command in emacs-lisp-mode. The prompt for the keywords repeats until the user submits the empty input. Currently there is no way to finish this input with selectrum.

To behave like the default interface selectrum shouldn't accept submitting a string which is not in the completion list but should allow submitting the empty string.

Most helpful comment

This should now be fixed!

All 4 comments

I'm hitting this bug too, here's a repro:

;; Run with `emacs -Q -l test.el'.

;;; Code:

;; Typical `straight.el' setup.
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

;; Insert repro code here:
(straight-use-package 'selectrum)
(selectrum-mode)
(auto-insert-mode)

Now C-x C-f foo.el RET y RET lisp RET RET ... stuck, can't escape

Ah, I found another thing that doesn't work well with this, vc-git-grep. The default value when it prompts for a file pattern isn't selected (although C-p let's me pull it up), and then when it queries for the directory, I can't select the current path in the prompt, it only lets me select children. I'm going to test your PR to see if this is fixed too...

(Ironic pattern of what's broken: built-in but perhaps slightly obscure Emacs functionality that most people seem to use "modern" packages to replace, but that I find useful!)

This should now be fixed!

@andschwa

The default value when it prompts for a file pattern isn't selected

122 will address this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

grolongo picture grolongo  路  10Comments

Compro-Prasad picture Compro-Prasad  路  7Comments

clemera picture clemera  路  5Comments

WorldsEndless picture WorldsEndless  路  9Comments

piranha picture piranha  路  7Comments