2

I've downloaded a new layout from https://qwerty-lafayette.org/ which I would like to use. However I am struggling to understand how I can use it inside Emacs. Usually I set languages by using (set-input-method "language"). However here I can't select the language, how can I do this for this particular language?

1 Answer 1

1

AFAIK there's not much documentation for the quail / leim stuff in Emacs; but once you know where to look, you can generally muddle your way through based on existing cases (there are so many of them, that there's generally likely to be something similar to use as a basis).

See M-x find-library RET leim-list for all of the register-input-method calls. To pick an example with a keyboard layout:

(register-input-method
 "english-dvorak" "English" 'quail-use-package
 "DV@" "English (ASCII) input method simulating Dvorak keyboard"
 "quail/latin-post")

The following is then a verbatim quote of the english-dvorak input method and keyboard layout from that quail/latin-post library. I believe that the call to quail-define-rules is automatically using the most-recent quail-define-package declaration, so this is pretty much all there is.

Note that you can visit that library with M-x find-library RET quail/latin-post (type it verbatim; completion won't complete it), and of course the many other files in the same directory provide other different examples.

Checking your link, I guess the better examples to look at are the french-keyboard and french-azerty input methods (which are also in latin-post.el). Once you have this working, perhaps you could contribute it upstream alongside those?

(require 'quail)

(quail-define-package
 "english-dvorak" "English" "DV@" t
 "English (ASCII) input method simulating Dvorak keyboard"
 nil t t t t nil nil nil nil nil t)

;; 1!  2@  3#  4$  5%  6^  7&  8*  9(  0)  [{  ]}  `~
;;  '"  ,<  .>  pP  yY  fF  gG  cC  rR  lL  /?  =+
;;   aA  oO  eE  uU  iI  dD  hH  tT  nN  sS  -_  \|
;;    ;:  qQ  jJ  kK  xX  bB  mM  wW  vV  zZ

(quail-define-rules
 ("-" ?\[)
 ("=" ?\])
 ("`" ?`)
 ("q" ?')
 ("w" ?,)
 ("e" ?.)
 ("r" ?p)
 ("t" ?y)
 ("y" ?f)
 ("u" ?g)
 ("i" ?c)
 ("o" ?r)
 ("p" ?l)
 ("[" ?/)
 ("]" ?=)
 ("a" ?a)
 ("s" ?o)
 ("d" ?e)
 ("f" ?u)
 ("g" ?i)
 ("h" ?d)
 ("j" ?h)
 ("k" ?t)
 ("l" ?n)
 (";" ?s)
 ("'" ?-)
 ("\\" ?\\)
 ("z" ?\;)
 ("x" ?q)
 ("c" ?j)
 ("v" ?k)
 ("b" ?x)
 ("n" ?b)
 ("m" ?m)
 ("," ?w)
 ("." ?v)
 ("/" ?z)

 ("_" ?{)
 ("+" ?})
 ("~" ?~)
 ("Q" ?\")
 ("W" ?<)
 ("E" ?>)
 ("R" ?P)
 ("T" ?Y)
 ("Y" ?F)
 ("U" ?G)
 ("I" ?C)
 ("O" ?R)
 ("P" ?L)
 ("{" ??)
 ("}" ?+)
 ("A" ?A)
 ("S" ?O)
 ("D" ?E)
 ("F" ?U)
 ("G" ?I)
 ("H" ?D)
 ("J" ?H)
 ("K" ?T)
 ("L" ?N)
 (":" ?S)
 ("\"" ?_)
 ("|" ?|)
 ("Z" ?:)
 ("X" ?Q)
 ("C" ?J)
 ("V" ?K)
 ("B" ?X)
 ("N" ?B)
 ("M" ?M)
 ("<" ?W)
 (">" ?V)
 ("?" ?Z)
 )

For a minimal example of a layout which switches the "f" and "o" characters, you could put this in your init file:

(add-to-list 'load-path (expand-file-name "~/.emacs.d/lisp"))

(register-input-method
 "foo" "French" 'quail-use-package
 "FOO@" "Example input method"
 "foo-input-method")

And create a file ~/.emacs.d/lisp/foo-input-method.el containing:

(require 'quail)

(quail-define-package
 "foo" "Foo" "Foo" t
 "Example input method"
 nil t t t t nil nil nil nil nil t)

(quail-define-rules
 ("F" ?O)
 ("f" ?o)
 ("O" ?F)
 ("o" ?f)
 )

(provide 'foo-input-method)
3
  • Ok, if I understood you correctly all the keyboard definitions are found in latin-post.el and I would have to change it manually and add this french-lafayette layout? (For me the file by the way is named leim/qual/latin-post.el.gz). I will think about adding additional french keyboard definition if I will have time, but since I haven't contributed anything until now, I probably won't find the energy to figure out how this contribution thing is working.
    – Rareform
    Dec 12, 2021 at 11:22
  • 1
    M-x report-emacs-bug will provide an email template you can use for sending in a feature request.
    – phils
    Dec 12, 2021 at 12:01
  • If you're just doing it for yourself, though, you can add the code to your init file, or to any other file that you load.
    – phils
    Dec 12, 2021 at 12:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.