Subject: Re: bug#14957: 24.3.50; Flyspell language visible in mode line

From: "Sebastien Vauban" <[email-masked]>
Date: Tue, 12 Nov 2013 14:29:57 +0100

Hello Michael,

Michael Heerdegen wrote:
>> (add-to-list 'mode-line-format
>>              '(:eval
>>                (let ((dict (and (featurep 'ispell)
>>                                 (or ispell-local-dictionary
>>                                     ispell-dictionary))))
>>                  (and dict
>>                       (concat " ["
>>                               (propertize (substring dict 0 2)
>>                                           'face 'mode-line-highlight)
>>                               "]"))))
>
> That's not good.  `mode-line-format' "automatically becomes buffer-local
> when set" (see C-h v).  Your `add-to-list' only manipulates the
> `mode-line-format' of the current buffer when your code is evaluated
> (*scratch*, probably).
>
> You have to modify the default value, like this:
>
> (setq-default mode-line-format
> 	      (cons
> 	       '(:eval
> 		 (let ((dict (and (featurep 'ispell)
> 				  (or ispell-local-dictionary
> 				      ispell-dictionary))))
> 		   (and dict
> 			(concat " ["
> 				(propertize (substring dict 0 2)
> 					    'face 'mode-line-highlight)
> 				"]"))))
> 	       (default-value 'mode-line-format)))
>
> Does that help?

Yes, it does.

However, I still wonder how to put the language indicator at the *end* of the
modeline -- I tried this at first, but I'm now sure it's not a good idea.

We can't do that by inverting the two components in the above cons expression.
And it seems I'm not yet bilingual enough in Lisp...

FYI, there is one minor annoyance; I'd like to see the language indicator only
where it makes sense, that is NOT in (almost) every buffer. For example, I do
see "fr" (my default dictionary) in the Emacs manuals, which is twice wrong:

- they're in English, and
- they're read-only...

I guess the read-only feature is the way to specify (in an automatic way) the
visibility (by default) of that feature. WDYT?  In such a case, we simply have
to add a condition in the above "and" expression.

Best regards,
  Seb

-- 
Sebastien Vauban