abo-abo / avy

Jump to things in Emacs tree-style
1.71k stars 109 forks source link

avy-goto-char-in-line fails in inferior-REPL prompts #285

Closed bymoz089 closed 4 years ago

bymoz089 commented 4 years ago

avy-goto-char-in-line fails when point is at the beginning of a REPL prompt.
Reason is, those pompts are fields and regexp-quote can't jump over fields.

Possible Solution: set variable inhibit-field-text-motion to 't.

(defun avy-goto-char-in-line (char)
  "Jump to the currently visible CHAR in the current line."
  (interactive (list (read-char "char: " t)))
  (let ((inhibit-field-text-motion t))
    (avy-with avy-goto-char
      (avy-jump
       (regexp-quote (string char))
       :beg (line-beginning-position)
       :end (line-end-position)))))

How to reproduce the bug:

  1. start inferior lisp repl M-x ielm
  2. enter some random text at the promt (to be able jump to it later)
  3. jump with avy-goto-line to a line, which contains a repl prompt. So point is at E of ELISP>
  4. try to call avy-goto-char-in-line (it wil fail, with "zero candidates" message)

Edit: this issue is present in all comint-derived modes like M-x shell M-x ielm and in slime.
Emacs manual: Shell Prompts
Emacs manual: Fields

abo-abo commented 4 years ago

Question is, why would you want to go there? Suppose you have:

ELISP> emacs

Pressing C-a takes you to the beginning of emacs, not the beginning of ELISP>. We could also advice beginning-of-line to bind inhibit-field-text-motion, but why? The current behavior is on purpose. Unless I'm missing something.

bymoz089 commented 4 years ago

My point lands very often at the beginning of those lines, as described in the reproduction example.
But since you wrote: the behavior is intended, I'll close this issue and write a small wrapper function for the avy-goto-char-in-line command into my initrc.