Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Changing language input method by addressee
@ 2018-03-09  5:13 Bob Newell
  2018-03-09  7:15 ` Eric Abrahamsen
  0 siblings, 1 reply; 6+ messages in thread
From: Bob Newell @ 2018-03-09  5:13 UTC (permalink / raw)
  To: info-gnus-english

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 *


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-03-09 19:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-09  5:13 Changing language input method by addressee Bob Newell
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

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).