help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to enter for example \200 offered by ispell in its buffer *Choic


From: Oleh Krehel
Subject: Re: How to enter for example \200 offered by ispell in its buffer *Choices*
Date: Mon, 22 Jun 2015 12:46:19 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Emanuel Berg <embe8573@student.uu.se> writes:

> Question: Is there anyone who succeeded or saw
> a solution that had the selection keys changed -
> I don't want to reach for the number keys, I want the
> first suggestion to be (a), then (s), (d), and (f),
> and/or likewise instantly available keys. It shouldn't
> be in alphabetic or numerical order (IMHO) it should
> be in the order of closeness which is a function of
> where they keys are on the keyboard. This is one of
> very, very few things I didn't succeed in getting the
> way I want with all of Emacs, Gnus, w3m etc. so if
> anyone has a solution I would readily let go of
> "100" of my hard-earned reputation.
> No fingers crossed!

The selection itself should be possible to achieve with avy.el
(https://elpa.gnu.org/packages/avy.html). It extends to as many
candidates as you can fit on a screen, and the decision chars are
composed of a user-defined set, e.g. "a", "s", "d", "fa", "fs", "fd".

A screenshot of using `avy-goto-word-0' on a buffer of German words:

Attachment: avy-ispell.png
Description: PNG image

Here, to jump to e.g. "Abführmittel", a user can press "kj". In this
case, the dictionary is "[asdfghjkl]" - the full home row. In case the
dictionary is "[a-zA-Z]", it's likely that most candidates can be
selected with just one char, just like with `ispell' currently.

To make `avy' work with `ispell', only two steps are necessary:

1. Make `ispell' put its candidates in a buffer.
2. Call `avy-goto-word-0' and pass the selected word back to `ispell'.

Here's a crude (but working) implementation:

(defun ispell-command-loop (miss guess word start end)
  (let ((wnd (selected-window)))
    (pop-to-buffer "*avy-ispell*")
    (erase-buffer)
    (insert (mapconcat #'identity miss " "))
    (setq truncate-lines nil)
    (avy-goto-word-0 nil)
    (let ((selected (thing-at-point 'word)))
      (select-window wnd)
      selected)))

Maybe someone interested and more knowledgeable about ispell.el could
refine this implementation.

Oleh

reply via email to

[Prev in Thread] Current Thread [Next in Thread]