[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: automatically change input method based on context
From: |
Charles A. Roelli |
Subject: |
Re: automatically change input method based on context |
Date: |
Sat, 21 Jan 2017 20:19:33 +0100 |
Hi Stefan,
Thanks for your help.
Here's a full example should anyone be interested:
(defun my-font-lock-comment-to-cursor-sensor (start end &rest _)
(save-excursion
(goto-char start)
(while (< (point) end)
(if (not (eq (get-text-property (point) 'face)
'font-lock-comment-face))
(goto-char (or (text-property-any (point) end 'face
'font-lock-comment-face)
end))
(let ((s (point)))
(goto-char (or (text-property-not-all (point) end 'face
'font-lock-comment-face)
end))
(put-text-property s (point) 'cursor-sensor-functions
'(motion-set-input-method)))))))
(defun motion-set-input-method (_window _oldpos dir)
(pcase dir
('entered (set-input-method "french-prefix"))
('left (set-input-method nil))))
(cursor-sensor-mode 1)
(advice-add 'font-lock-fontify-syntactically-region :after
#'my-font-lock-comment-to-cursor-sensor)
Cheers,
Charles