[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How do you write input methods?
From: |
Eli Zaretskii |
Subject: |
Re: How do you write input methods? |
Date: |
Thu, 02 Sep 2021 09:23:14 +0300 |
> From: Filipp Gunbin <fgunbin@fastmail.fm>
> Cc: andremegafone@gmail.com, perry@piermont.com, emacs-devel@gnu.org
> Date: Wed, 01 Sep 2021 23:33:51 +0300
>
> > 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.
So what you need is to apply the cyrillic-translit input method, just
not in an interactive context, is that true?