unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to enter for example \200 offered by ispell in its buffer *Choices*
@ 2015-06-21 19:34 Jürgen Hartmann
  2015-06-21 19:42 ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Jürgen Hartmann @ 2015-06-21 19:34 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

The options offered by Ispell in the buffer *Choices* are associated with
characters--actually keys--that can be entered to select the respective
option. If there are not too many options, digits and letters are sufficient
to identify any of them. But from time to time it happens that there are

If there are many options, digits and letters are not sufficient to identify
each of them. In that case ispell (more precisely the function
ispell-command-loop) also uses characters as ^? and \200.

The following example shows such a situation: These are the options presented
in the buffer *Choices* after doing a ispell-complete-word on "Abf" using
Hunspell together with a German alternate dictionary.

-----------------------------------------------------------------------------
(0) Abfälle  (1) Abfällen  (2) Abfahrt  (3) Abfahrten  (4) Abfahrtshänge
(5) Abfahrtshängen  (6) Abfahrtshang  (7) Abfahrtsläufer
(8) Abfahrtsläuferin  (9) Abfahrtsläuferinnen  (:) Abfahrtsläufern
(;) Abfahrtsrennen  (<) Abfahrtsstelle  (=) Abfahrtsstellen
(>) Abfahrtsstrecke  (@) Abfahrtsstrecken  (B) Abfall  (C) Abfalls
(D) Abfallaufbereitung  (E) Abfalleimer  (F) Abfalleimern
(G) Abfallgraben  (H) Abfallkurve  (I) Abfallkurven  (J) Abfallpapier
(K) Abfallpapiers  (L) Abfallprodukt  (M) Abfallprodukten
(N) Abfallprodukts  (O) Abfallproduktes  (P) Abfallstoffe
(Q) Abfallstoffen  (S) Abfangjäger  (T) Abfangjägern  (U) Abfangjägers
(V) Abfangrakete  (W) Abfangraketen  (Y) Abfassung  (Z) Abfassungen
([) Abfertigung  (\) Abfertigungen  (]) Abfertigungsschalter
(^) Abfertigungsschaltern  (_) Abfertigungsschalters
(`) Abfertigungsstelle  (b) Abfertigungsstellen  (c) Abfindung
(d) Abfindungen  (e) Abflachung  (f) Abflachungen  (g) Abflüge
(h) Abflügen  (j) Abflüsse  (k) Abflüssen  (n) Abflug  (o) Abflugs
(p) Abflugflughafen  (s) Abflugland  (t) Abfluß  (v) Abflusses
(w) Abfördermenge  (y) Abfördermengen  (z) Abfolge  ({) Abfolgen
(|) Abfragesprache  (}) Abfragesprachen  (~) Abführmittel
(^?) Abführmitteln  (\200) Abführmittels  (\201) Abführung
(\202) Abfüllanlage  (\203) Abfüllanlagen  (\204) Abfüllfiliale
(\205) Abfüllfilialen  (\206) Abfüllstation  (\207) Abfüllstationen
(\210) Abfuhr  (\211) Abfuhren
-----------------------------------------------------------------------------

Now the question: How do I enter ^? or \200 in this situation?

I gave C-x 8 RET which is bound to insert-char a try, but C-x was ignored and
pressing 8 lead to the selection of Option (8).

NB: ispell-command-loop uses read-key to read the users choice.

Is there some kind of input method or key-map that allows to enter such
characters (or keys) in this case?

Juergen

 		 	   		  


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to enter for example \200 offered by ispell in its buffer *Choices*
  2015-06-21 19:34 How to enter for example \200 offered by ispell in its buffer *Choices* Jürgen Hartmann
@ 2015-06-21 19:42 ` Eli Zaretskii
  2015-06-21 21:19   ` Jürgen Hartmann
       [not found]   ` <mailman.5398.1434921573.904.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 10+ messages in thread
From: Eli Zaretskii @ 2015-06-21 19:42 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Jürgen Hartmann <juergen_hartmann_@hotmail.com>
> Date: Sun, 21 Jun 2015 21:34:15 +0200
> 
> (^?) Abführmitteln  (\200) Abführmittels  (\201) Abführung
> (\202) Abfüllanlage  (\203) Abfüllanlagen  (\204) Abfüllfiliale
> (\205) Abfüllfilialen  (\206) Abfüllstation  (\207) Abfüllstationen
> (\210) Abfuhr  (\211) Abfuhren
> -----------------------------------------------------------------------------
> 
> Now the question: How do I enter ^? or \200 in this situation?

^? with C-q and \200 with "C-x 8 RET 80 RET".  But see below.

> I gave C-x 8 RET which is bound to insert-char a try, but C-x was ignored and
> pressing 8 lead to the selection of Option (8).
> 
> NB: ispell-command-loop uses read-key to read the users choice.
> 
> Is there some kind of input method or key-map that allows to enter such
> characters (or keys) in this case?

Please report this as a bug.  Ispell should offer printable
characters, not control characters.  E.g., instead of \200, it should
use ä or some such.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to enter for example \200 offered by ispell in its buffer *Choices*
       [not found] <mailman.5388.1434915264.904.help-gnu-emacs@gnu.org>
@ 2015-06-21 20:35 ` Emanuel Berg
  2015-06-21 22:01   ` Jürgen Hartmann
                     ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Emanuel Berg @ 2015-06-21 20:35 UTC (permalink / raw)
  To: help-gnu-emacs

Jürgen Hartmann <juergen_hartmann_@hotmail.com>
writes:

> (0) Abfälle  (1) Abfällen  (2) Abfahrt  (3) Abfahrten 
> (4) Abfahrtshänge (5) Abfahrtshängen  (6)
> Abfahrtshang  (7) Abfahrtsläufer (8) Abfahrtsläuferin 
> (9) Abfahrtsläuferinnen  (:) Abfahrtsläufern (;)
> Abfahrtsrennen  (<) Abfahrtsstelle  (=)
> Abfahrtsstellen (>) Abfahrtsstrecke  (@)
> Abfahrtsstrecken  (B) Abfall  (C) Abfalls (D)
> Abfallaufbereitung  (E) Abfalleimer  (F) Abfalleimern
> (G) Abfallgraben  (H) Abfallkurve  (I) Abfallkurven 
> (J) Abfallpapier (K) Abfallpapiers  (L) Abfallprodukt 
> (M) Abfallprodukten (N) Abfallprodukts  (O)
> Abfallproduktes  (P) Abfallstoffe (Q) Abfallstoffen 
> (S) Abfangjäger  (T) Abfangjägern  (U) Abfangjägers
> (V) Abfangrakete  (W) Abfangraketen  (Y) Abfassung 
> (Z) Abfassungen ([) Abfertigung  (\) Abfertigungen 
> (]) Abfertigungsschalter (^) Abfertigungsschaltern 
> (_) Abfertigungsschalters (`) Abfertigungsstelle  (b)
> Abfertigungsstellen  (c) Abfindung (d) Abfindungen 
> (e) Abflachung  (f) Abflachungen  (g) Abflüge (h)
> Abflügen  (j) Abflüsse  (k) Abflüssen  (n) Abflug  (o)
> Abflugs (p) Abflugflughafen  (s) Abflugland  (t)
> Abfluß  (v) Abflusses (w) Abfördermenge  (y)
> Abfördermengen  (z) Abfolge  ({) Abfolgen (|)
> Abfragesprache  (}) Abfragesprachen  (~) Abführmittel
> (^?) Abführmitteln  (\200) Abführmittels  (\201)
> Abführung (\202) Abfüllanlage  (\203) Abfüllanlagen 
> (\204) Abfüllfiliale (\205) Abfüllfilialen  (\206)
> Abfüllstation  (\207) Abfüllstationen (\210) Abfuhr 
> (\211) Abfuhren

(re-search-forward "^Question:")

Wow! You sure get many suggestions when making
mistakes in German!

To (not) answer your question: I don't know.

But I thought I'd share my ispell setup since it isn't
often I run into another user. I am Swedish so I use
the american-insane as well as the Swedish spellcheck.
I have that `C-o e' for "spell-english" (see the file)
and `C-o s' for ditto Swedish.

It has some DWIM features and calls different
functions depending on region, mode (e.g.,
message-mode, programming, etc.) - or that's the
thought. But it works nine times out of then:

    http://user.it.uu.se/~embe8573/conf/emacs-init/spell.el

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!

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: How to enter for example \200 offered by ispell in its buffer *Choices*
  2015-06-21 19:42 ` Eli Zaretskii
@ 2015-06-21 21:19   ` Jürgen Hartmann
       [not found]   ` <mailman.5398.1434921573.904.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 10+ messages in thread
From: Jürgen Hartmann @ 2015-06-21 21:19 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Thank you Eli Zaretskii for your rapid answer:

>> Now the question: How do I enter ^? or \200 in this situation?
>
> ^? with C-q and \200 with "C-x 8 RET 80 RET".  But see below.

Unfortunately this doesn't work.

Since ispell-command-loop uses the function read-key to get the users answer,
it is not straight forward to use

   C-q

or

   C-x 8 RET

sequences: C-q is instantaneously read as ^q and C-x as ^x. Both are
discarded immediately by ispell-command-loop as wrong input, so they can not
be used to build sequences.

> Please report this as a bug.  Ispell should offer printable
> characters, not control characters.  E.g., instead of \200, it should
> use ä or some such.

I will do this.

Of course one might ask whether it is useful to offer such a mass of options.
Maybe it would be enough to limit their number.

But however: Is there a method--some translation keymaps or
something alike--that allows to enter a key code numerically to read-key?

Juergen

 		 	   		  


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to enter for example \200 offered by ispell in its buffer *Choices*
       [not found]   ` <mailman.5398.1434921573.904.help-gnu-emacs@gnu.org>
@ 2015-06-21 21:43     ` Emanuel Berg
  2015-06-21 23:02       ` Jürgen Hartmann
  0 siblings, 1 reply; 10+ messages in thread
From: Emanuel Berg @ 2015-06-21 21:43 UTC (permalink / raw)
  To: help-gnu-emacs

Jürgen Hartmann <juergen_hartmann_@hotmail.com>
writes:

> But however: Is there a method--some translation
> keymaps or something alike--that allows to enter
> a key code numerically to read-key?

Try this:

    (push ?\200 unread-command-events)

-- 
underground experts united
http://user.it.uu.se/~embe8573


^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: How to enter for example \200 offered by ispell in its buffer *Choices*
  2015-06-21 20:35 ` Emanuel Berg
@ 2015-06-21 22:01   ` Jürgen Hartmann
  2015-06-22 10:46   ` Oleh Krehel
  2015-06-27 11:33   ` Jürgen Hartmann
  2 siblings, 0 replies; 10+ messages in thread
From: Jürgen Hartmann @ 2015-06-21 22:01 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Thank you Emanuel Berg for your answer:

> Wow! You sure get many suggestions when making
> mistakes in German!

That's because in principle you can compose any number of nouns to a valid
German word. But fortunately Hunspell limits its suggestions to a reasonable
selection.

The example I showed is an extreme case, as it was taken from a word
completion (ispell-complete-word) not from a spell check.

But it leads to the question how to enter such keystrokes.

> To (not) answer your question: I don't know.
>
> But I thought I'd share my ispell setup since it isn't
> often I run into another user. I am Swedish so I use
> the american-insane as well as the Swedish spellcheck.
> I have that `C-o e' for "spell-english" (see the file)
> and `C-o s' for ditto Swedish.

Thank you very much!

That's what I stumble over regularly too: Always the wrong
dictionary is selected.

> It has some DWIM features and calls different
> functions depending on region, mode (e.g.,
> message-mode, programming, etc.) - or that's the
> thought. But it works nine times out of then:
>
>     http://user.it.uu.se/~embe8573/conf/emacs-init/spell.el

There are very nice ideas in your setup: I have bound ispell-message,
ispell-comments-and-strings and friends individually to some keys that I
can't remember when i need them. So I think your DWIM attempt is a very
helpful thing.

> 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!

As far as I see from the definition of ispell-command-loop, it just assigns
the characters (!) starting from digit 0 upward, skipping the characters that
are used for the fixed commands like <SPC>, i, x, X, q and the like.

I think it should instead be possible to choose them out of a list that holds
them in any desired order. But I never saw something like that realized.

Juergen

 		 	   		  


^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: How to enter for example \200 offered by ispell in its buffer *Choices*
  2015-06-21 21:43     ` Emanuel Berg
@ 2015-06-21 23:02       ` Jürgen Hartmann
  0 siblings, 0 replies; 10+ messages in thread
From: Jürgen Hartmann @ 2015-06-21 23:02 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

@ Emanuel Berg: Thank you for your suggestion:

> Jürgen Hartmann <juergen_hartmann_@hotmail.com>
> writes:
>
>> But however: Is there a method--some translation
>> keymaps or something alike--that allows to enter
>> a key code numerically to read-key?
>
> Try this:
>
>     (push ?\200 unread-command-events)

Good idea.

But I didn't succeed to apply it.

As a mockup for the situation in ispell-command-loop I defined

   (defun test ()
     ""
     (dotimes (i 10)
       (let ((key (read-key)))
         (message "Key: %s" key))))

which does read-key ten times and outputs the keys read in messages.

But running this function I can not issue the push expression. Even if I
define it as a command and bind it to a key, only that key is read verbatim
like C-f5.

Seems to be a teaser.

Thank you again for your input.

Juergen

 		 	   		  


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to enter for example \200 offered by ispell in its buffer *Choices*
  2015-06-21 20:35 ` Emanuel Berg
  2015-06-21 22:01   ` Jürgen Hartmann
@ 2015-06-22 10:46   ` Oleh Krehel
  2015-06-27 11:34     ` Jürgen Hartmann
  2015-06-27 11:33   ` Jürgen Hartmann
  2 siblings, 1 reply; 10+ messages in thread
From: Oleh Krehel @ 2015-06-22 10:46 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1031 bytes --]

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 #2: avy-ispell.png --]
[-- Type: image/png, Size: 90327 bytes --]

[-- Attachment #3: Type: text/plain, Size: 970 bytes --]


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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: How to enter for example \200 offered by ispell in its buffer *Choices*
  2015-06-21 20:35 ` Emanuel Berg
  2015-06-21 22:01   ` Jürgen Hartmann
  2015-06-22 10:46   ` Oleh Krehel
@ 2015-06-27 11:33   ` Jürgen Hartmann
  2 siblings, 0 replies; 10+ messages in thread
From: Jürgen Hartmann @ 2015-06-27 11:33 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Emanuel Berg wrote:

> 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.

I posted a workaround for my problem in

   http://lists.gnu.org/archive/html/bug-gnu-emacs/2015-06/msg00981.html

as an answer to my bug report. It might also help in your case, since it
allows to customize the option keys and their order that Ispell's command
loop uses--at least it is supposed to.

Juergen

 		 	   		  


^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: How to enter for example \200 offered by ispell in its buffer *Choices*
  2015-06-22 10:46   ` Oleh Krehel
@ 2015-06-27 11:34     ` Jürgen Hartmann
  0 siblings, 0 replies; 10+ messages in thread
From: Jürgen Hartmann @ 2015-06-27 11:34 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Thank you Oleh Krehel for your suggestion:

> 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".

The package avy.el seems to provide the tools for a very professional
solution for such kind of issues.

> 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.

I don't think that short key sequences would be a big obstacle here. After
all, they are easier to perform than C-M-AltGr-something-else-<single key>,
which would be the necessary if one tries to map many options to a rather
limited number of single keys. So this also pleads for avy.el.

> 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)))

Good enough to show the principle.

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

That would be great. Unfortunately I am not able to do that myself, but I
have posted a crude workaround for the issues at hand in

   http://lists.gnu.org/archive/html/bug-gnu-emacs/2015-06/msg00981.html

that is by far not so professional as an avy.el solution would be.

Juergen

 		 	   		  


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-06-27 11:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-21 19:34 How to enter for example \200 offered by ispell in its buffer *Choices* Jürgen Hartmann
2015-06-21 19:42 ` Eli Zaretskii
2015-06-21 21:19   ` Jürgen Hartmann
     [not found]   ` <mailman.5398.1434921573.904.help-gnu-emacs@gnu.org>
2015-06-21 21:43     ` Emanuel Berg
2015-06-21 23:02       ` Jürgen Hartmann
     [not found] <mailman.5388.1434915264.904.help-gnu-emacs@gnu.org>
2015-06-21 20:35 ` Emanuel Berg
2015-06-21 22:01   ` Jürgen Hartmann
2015-06-22 10:46   ` Oleh Krehel
2015-06-27 11:34     ` Jürgen Hartmann
2015-06-27 11:33   ` Jürgen Hartmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).