From: Bob Newell <bobnewell@bobnewell.net>
To: info-gnus-english <info-gnus-english@gnu.org>
Subject: Changing language input method by addressee
Date: Thu, 08 Mar 2018 19:13:09 -1000 [thread overview]
Message-ID: <87lgf1vnkq.fsf@bobnewell.net> (raw)
Aloha everyone,
I mostly correspond in English, but I have a few French correspondents
and a couple of German ones. So I wanted to automatically enter French
input mode or German input mode respectively when writing to one of
those folks. After an embarrassing amount of time I came up with
something that works. (I'm on Emacs 25.3 and corresponding Gnus, and I
use message mode, gnus-alias, and BBDB completion. Obviously, I've
anonymized the addressees.)
--
(defun rjn-change-lang-by-addressee (&rest args)
(let* ((addressee (message-fetch-field "To")))
(if addressee
(if (or
(string-match-p "french1" addressee)
(string-match-p "french2" addressee)
(string-match-p "french3" addressee)
(string-match-p "french4" addressee)
(string-match-p "french5" addressee)
(string-match-p "french6" addressee)
(string-match-p "french7" addressee)
(string-match-p "french8" addressee))
(set-input-method "french-postfix")
(if (or
(string-match-p "german1" addressee)
(string-match-p "german2" addressee)
(string-match-p "german3" addressee))
(set-input-method "german-postfix"))))))
(add-hook 'message-setup-hook 'rjn-change-lang-by-addressee t)
(advice-add 'bbdb-complete-mail :after #'rjn-change-lang-by-addressee)
--
But this seems excessively crude and clunky. Surely I'm not the first
person ever to do this sort of thing, but I can't find any other
examples.
Any suggestions about doing this better, perhaps much better?
Mahalo,
--
Bob Newell
Honolulu, Hawai`i
* Via Gnus/BBDB/Org/Emacs/Linux *
next reply other threads:[~2018-03-09 5:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-09 5:13 Bob Newell [this message]
2018-03-09 7:15 ` Eric Abrahamsen
2018-03-09 17:02 ` Bob Newell
2018-03-09 19:18 ` Tim Landscheidt
2018-03-09 19:36 ` Bob Newell
2018-03-09 19:29 ` Bob Newell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lgf1vnkq.fsf@bobnewell.net \
--to=bobnewell@bobnewell.net \
--cc=info-gnus-english@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).