In the comments you said you wanted to depend on the Windows language bar. The Windows Get-WinDefaultInputMethodOverride Cmdlet in Window PowerShell provides the necessary information.
Thus, when creating a new buffer, you need to run PowerShell Get-WinDefaultInputMethodOverride
and parse the ouput. If you do this for every buffer, even for temporary buffers, my guess is that this slow you down very much. It would be better to write a function that can be added to hooks such as find-file-hooks
. The functions on this hook are only called when you open a file for editing.
Calling a command and capturing the output happens using (shell-command-to-string COMMAND)
. Comparing a string to some other values happens via (string-match REGEXP STRING)
. Setting the font for a particular buffer involves calling (face-remap-add-relative FACE &rest SPECS)
. The face you are interested in is called default
. The specs you want are :family
and :height
, the font family and the font size in tenths of points.
Thus, perhaps (untested, since I'm not on Windows):
(defun my-buffer-setup ()
(let ((output (shell-command-to-string "PowerShell Get-WinDefaultInputMethodOverride")))
(cond ((string-match "arabic" output)
(face-remap-add-relative 'default :family "DejaVu Sans Mono" :height 140))
((string-match "english" output)
(face-remap-add-relative 'default :family "Consolas" :height 110))
((string-match "german" output)
(face-remap-add-relative 'default :family "Consolas" :height 120)))))
(add-hook 'find-file-hook 'my-buffer-setup)
Good luck. :)