1

It's pretty annoying when I hold down Backspace one character too long in the minibuffer, causing Ivy to quit and then accidentally deleting some characters in the main buffer I'm working in.

How do I change this behaviour?

5

Ivy provides a user option to control this behaviour. Quoth (ivy) Defcustoms (edit mine):

-- User Option: ivy-on-del-error-function
    Specify what [to do] when ‘DEL’ (‘ivy-backward-delete-char’) throws.

    The default behavior is to quit the completion after ‘DEL’ – a
    handy key to invoke after mistakenly triggering a completion.

and C-hvivy-on-del-error-functionRET:

ivy-on-del-error-function is a variable defined in ‘ivy.el’.
Its value is ‘minibuffer-keyboard-quit’

  This variable may be risky if used as a file-local variable.

Documentation:
The handler for when ‘ivy-backward-delete-char’ throws.
Usually a quick exit out of the minibuffer.

Granted, the documentation is a bit lacking, but, as the name suggests, this user option can be set to a function to be called when the user presses DEL one too many times. The simplest setting is to do nothing, i.e.:

(setq ivy-on-del-error-function #'ignore)

You can also set this user option to ignore via M-xcustomize-variableRETivy-on-del-error-functionRET, if you prefer to use the Custom interface.

  • Ohhh ok. I forgot to put setq when I was trying that. Just curious, what's the difference between #'ignore and 'ignore? And what file is Specify what [to do] when ‘DEL’ (‘ivy-backward-delete-char’) throws. in? I can't seem to find it. – John DeBord Apr 21 '18 at 18:48
  • 1
    @JohnDeBord 'ignore is short for (quote ignore) and #'ignore is short for (function ignore). The value is the same symbol, but the latter tells the byte-compiler and readers that this symbol is intended to be used as a function. See (elisp) Anonymous Functions for more information. – Basil Apr 21 '18 at 18:54
  • 1
    @JohnDeBord I have already linked the (HTML) source of Specify what [to do]... in my answer - it is from the Ivy manual, whose Org source can be found here: github.com/abo-abo/swiper/blob/master/doc/ivy.org. – Basil Apr 21 '18 at 18:55
  • 1
    @JohnDeBord The following PR which tries to clarify the relevant documentation was merged today: github.com/abo-abo/swiper/pull/1535. – Basil Apr 23 '18 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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