[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How do you write input methods?
From: |
Filipp Gunbin |
Subject: |
Re: How do you write input methods? |
Date: |
Wed, 01 Sep 2021 23:33:51 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin) |
On 01/09/2021 20:57 +0300, Eli Zaretskii wrote:
>> From: Filipp Gunbin <fgunbin@fastmail.fm>
>> Cc: Eli Zaretskii <eliz@gnu.org>, perry@piermont.com, emacs-devel@gnu.org
>> Date: Wed, 01 Sep 2021 20:50:04 +0300
>>
>> FWIW, I use this (hack?) to employ available input methods for
>> transliteration.
>
> Out of curiosity: why do you need something like that? what's the use
> case?
It's because our LDAP server at work is a bit messy, attributes like
"cn" and "displayname" sometimes contain first then last name, sometimes
vice versa, sometimes in Russian, sometimes in English. I use email
expansion in message-mode:
--8<---------------cut here---------------start------------->8---
(eval-after-load 'message
(lambda ()
(define-key message-mode-map (kbd "C-c TAB") #'eudc-expand-inline)))
--8<---------------cut here---------------end--------------->8---
I want to type first letters of surname in English, press C-c TAB and
get email autocompleted. But the only "stable", predictable attribute
seems to be "sn", which is unfortunately in Russian. So I do:
--8<---------------cut here---------------start------------->8---
(eudc-protocol-set 'eudc-inline-query-format '((sn) (email)) 'ldap)
(advice-add #'eudc-ldap-simple-query-internal
:filter-args #'fg-dotemacs-ldap-advice)
(defun fg-dotemacs-ldap-advice (args)
(cons (mapcar (lambda (attr)
(if (and (eq (car attr) 'sn)
(stringp (cdr attr))
(seq-every-p (lambda (c)
(eq (aref char-script-table c)
'latin))
(cdr attr)))
(cons (car attr)
(fg-dotemacs-translit (cdr attr)
"cyrillic-translit"))
attr))
(car args))
(cdr args)))
--8<---------------cut here---------------end--------------->8---
As ugly as it is, but it works.
Filipp