unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Preventing accidental prefix match in input-method
@ 2018-11-23 16:40 Stefan Monnier
  2018-11-23 20:29 ` Michael Welsh Duggan
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2018-11-23 16:40 UTC (permalink / raw)
  To: emacs-devel; +Cc: K. Handa

I'd like to setup an input method where I have a mapping

    \b  =>  β

but where I'd like it that when the user enters `\beta`
the result is `\beta` rather than `βeta`.

I know I can do it by adding mappings

    \ba  =>  \ba
    \bb  =>  \bb
    \bc  =>  \bc
    \bd  =>  \bd
    \be  =>  \be
    ...

but that would blow up my input method by a factor 50.
Is there a better solution?


        Stefan



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

* Re: Preventing accidental prefix match in input-method
  2018-11-23 16:40 Preventing accidental prefix match in input-method Stefan Monnier
@ 2018-11-23 20:29 ` Michael Welsh Duggan
  2018-11-23 21:51   ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Welsh Duggan @ 2018-11-23 20:29 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: K. Handa, emacs-devel

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

> I'd like to setup an input method where I have a mapping
>
>     \b  =>  β
>
> but where I'd like it that when the user enters `\beta`
> the result is `\beta` rather than `βeta`.
>
> I know I can do it by adding mappings
>
>     \ba  =>  \ba
>     \bb  =>  \bb
>     \bc  =>  \bc
>     \bd  =>  \bd
>     \be  =>  \be
>     ...
>
> but that would blow up my input method by a factor 50.
> Is there a better solution?

Would adding a mapping from `βeta` to `\beta` work?

-- 
Michael Welsh Duggan
(md5i@md5i.com)



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

* Re: Preventing accidental prefix match in input-method
  2018-11-23 20:29 ` Michael Welsh Duggan
@ 2018-11-23 21:51   ` Stefan Monnier
  2018-11-23 22:47     ` Joost Kremers
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2018-11-23 21:51 UTC (permalink / raw)
  To: emacs-devel

>> I'd like to setup an input method where I have a mapping
>>
>>     \b  =>  β
>>
>> but where I'd like it that when the user enters `\beta`
>> the result is `\beta` rather than `βeta`.
>>
>> I know I can do it by adding mappings
>>
>>     \ba  =>  \ba
>>     \bb  =>  \bb
>>     \bc  =>  \bc
>>     \bd  =>  \bd
>>     \be  =>  \be
>>     ...
>>
>> but that would blow up my input method by a factor 50.
>> Is there a better solution?
>
> Would adding a mapping from `βeta` to `\beta` work?

I didn't mean that only `\beta` stays untouched, sorry.
`\big` should also stay as `\big` rather than be turned into `βig`, and
same for all other `\b<something>` where <something> is made up of
alphabetic characters.

IOW I'd like to be able to say something like "\b is rewritten to β but
only if immediately followed by a word boundary".


        Stefan




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

* Re: Preventing accidental prefix match in input-method
  2018-11-23 21:51   ` Stefan Monnier
@ 2018-11-23 22:47     ` Joost Kremers
  2018-11-23 23:03       ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Joost Kremers @ 2018-11-23 22:47 UTC (permalink / raw)
  To: emacs-devel


On Fri, Nov 23 2018, Stefan Monnier wrote:
>>> I'd like to setup an input method where I have a mapping
>>>
>>>     \b  =>  β
>>>
>>> but where I'd like it that when the user enters `\beta`
>>> the result is `\beta` rather than `βeta`.
>>>
>>> I know I can do it by adding mappings
>>>
>>>     \ba  =>  \ba
>>>     \bb  =>  \bb
>>>     \bc  =>  \bc
>>>     \bd  =>  \bd
>>>     \be  =>  \be
>>>     ...
>>>
>>> but that would blow up my input method by a factor 50.
>>> Is there a better solution?
>>
>> Would adding a mapping from `βeta` to `\beta` work?
>
> I didn't mean that only `\beta` stays untouched, sorry.
> `\big` should also stay as `\big` rather than be turned into 
> `βig`, and
> same for all other `\b<something>` where <something> is made up 
> of
> alphabetic characters.
>
> IOW I'd like to be able to say something like "\b is rewritten 
> to β but
> only if immediately followed by a word boundary".

You could always create mapping of the form "\b " (i.e., with a 
space) => β, but then you may need to add more mappings such as 
"\b.", "\b,", etc., all mapping to β. Also not ideal.

The way to deal with this, AFAICT, is to add a binding that 
effectively cancels the "special" character. For example, 
latin-9-prefix uses space for this: typing ' followed by a gives 
«á», but ' + space + a gives «'a». The TeX input method allows you 
to type backslash twice to get a single backslash.

So you could add a mapping from "\\" or "\ " to "\" and accustom 
yourself to typing "\\beta" or "\ beta" to get "\beta".


-- 
Joost Kremers
Life has its moments



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

* Re: Preventing accidental prefix match in input-method
  2018-11-23 22:47     ` Joost Kremers
@ 2018-11-23 23:03       ` Stefan Monnier
  2018-12-17  3:51         ` Amin Bandali
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2018-11-23 23:03 UTC (permalink / raw)
  To: emacs-devel

>> IOW I'd like to be able to say something like "\b is rewritten to β but
>> only if immediately followed by a word boundary".
[...]
> The way to deal with this, AFAICT, is to add a binding that effectively
> cancels the "special" character. For example, latin-9-prefix uses space for
> this: typing ' followed by a gives «á», but ' + space + a gives «'a». The
> TeX input method allows you to type backslash twice to get
> a single backslash.

Yes, that's what I do now.  Doubling backslash works well in cases where
it's only needed in unusual circumstances.

But I find it very inconvenient in latex-mode because I very frequently
need to type a normal \<something>.


        Stefan




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

* Re: Preventing accidental prefix match in input-method
  2018-11-23 23:03       ` Stefan Monnier
@ 2018-12-17  3:51         ` Amin Bandali
  0 siblings, 0 replies; 6+ messages in thread
From: Amin Bandali @ 2018-12-17  3:51 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On 2018-11-23  6:03 PM, Stefan Monnier wrote:
>
> Yes, that's what I do now.  Doubling backslash works well in cases where
> it's only needed in unusual circumstances.
>
> But I find it very inconvenient in latex-mode because I very frequently
> need to type a normal \<something>.

Seconded.

Stefan (and others), did you have a chance to think about / look further
into this?  I’d probably use any workaround, unsightly as it may be, if
it meant I’d get to keep the backslash prefix for the input, instead of
my changing it to the forwardslash—it’s a bit hard to rewire years of
muscle memory.

amin



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

end of thread, other threads:[~2018-12-17  3:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-23 16:40 Preventing accidental prefix match in input-method Stefan Monnier
2018-11-23 20:29 ` Michael Welsh Duggan
2018-11-23 21:51   ` Stefan Monnier
2018-11-23 22:47     ` Joost Kremers
2018-11-23 23:03       ` Stefan Monnier
2018-12-17  3:51         ` Amin Bandali

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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