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

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

Re: automatically change input method based on context


From: Phillip Lord
Subject: Re: automatically change input method based on context
Date: Sat, 21 Jan 2017 23:34:03 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

You might want to take a look at my package:

https://github.com/phillord/tmmofl

It does pretty what you want -- it runs a function when point enters
into text with a particular highlighting, and another when you move
out. I use it to turn auto-fill-mode on in comments and off everywhere
else.

It uses post-command-hook to do it's stuff.

Let me know how you get on!

charles@aurox.ch (Charles A. Roelli) writes:

> Hi,
>
> I'd like Emacs to switch input method automatically based on the
> font-lock face property of point.  As an example, if point is in a
> comment, Emacs should run `(set-input-method "french-prefix")', and then
> when point leaves the comment, `(set-input-method nil)' should run
> again.  I managed to do it with a timer (not really elegant), but it
> seems like this is something that would be possible with
> `cursor-sensor-mode'.
>
> My idea is to:
> 1. Add a `cursor-sensor-functions' property to all the text that is
>    fontified as a comment (and somehow keep this dynamically updated).
> 2. Use this function in `cursor-sensor-functions' to handle changing the
>    input method:
>
>    (defun motion-set-input-method (window oldpos dir)
>      (pcase dir
>        ('entered (set-input-method "french-prefix"))
>        ('left (set-input-method nil))))
>
> But I don't know how to go about (1).  Any advice?
>
> Cheers,
> Charles



reply via email to

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