From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: charles@aurox.ch (Charles A. Roelli) Newsgroups: gmane.emacs.help Subject: automatically change input method based on context Date: Thu, 19 Jan 2017 12:02:57 +0100 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1484834028 14032 195.159.176.226 (19 Jan 2017 13:53:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 19 Jan 2017 13:53:48 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jan 19 14:53:44 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cUD9o-0002vB-TE for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Jan 2017 14:53:41 +0100 Original-Received: from localhost ([::1]:48164 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cUD9s-0004UZ-Av for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Jan 2017 08:53:44 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59201) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cUAXC-00035U-Oe for help-gnu-emacs@gnu.org; Thu, 19 Jan 2017 06:05:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cUAX7-0003Cu-Lr for help-gnu-emacs@gnu.org; Thu, 19 Jan 2017 06:05:38 -0500 Original-Received: from [195.159.176.226] (port=45730 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cUAX7-0003C6-Ey for help-gnu-emacs@gnu.org; Thu, 19 Jan 2017 06:05:33 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cUAWd-0007Sa-5p for help-gnu-emacs@gnu.org; Thu, 19 Jan 2017 12:05:03 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 25 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:NxSE4ZiMLTjGAKiRmNYIj98kEj0= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-Mailman-Approved-At: Thu, 19 Jan 2017 08:53:10 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:112130 Archived-At: 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