2

I can activate the input method french-azerty by M-x set-input-method RET french-azerty. Then by a qwerty keyboard I can type like an azerty one. Thus typying q in the buffer gives a. But when I do M-: (insert "q") it gives q instead of a. Is there a way that the evaluations takes into account the chosen input-method? i.e. M-: (insert "qwerty") gives azerty?

Name
  • 7,689
  • 4
  • 38
  • 84
  • @phils I would like to write inserting macros/functions which uses the full functionality of a specific input-method (e.g. french-azerty). But it seems that `insert` bypasses the input-method. When `french-azerty` is activated, typying `qwerty` in the buffer gives `azerty`. I don't underestand why `(insert "qwerty")` doesn't gives `azerty`? So how an insert-method insert a text? A related [discussion][1] on SO allows to use an input method in minibuffer. [1]: http://stackoverflow.com/questions/15169428/use-the-default-input-method-when-doing-an-incremental-search-in-evil – Name Jan 11 '15 at 21:11
  • @phils If you are certain that an input-method cannot intervene when inserting, please convert your comments to an answer in order that I may be able to mark it as an accepted answer. – Name Jan 12 '15 at 12:44

1 Answers1

2

When you evaluate (insert "qwerty") the lisp reader creates a string object with the literal value "qwerty". No input method functionality is able to intervene there.

The input method has already done its work by the time a character is inserted into a buffer, such that (using your example) typing q would result in (insert "a"), not (insert "q").

insert itself is a very low-level function. The only manipulation that happens to its argument is to ensure that unibyte data is not inserted into a multibyte buffer, or vice versa.

However, if you're talking about writing a function to insert text into a buffer, there's absolutely no reason why you would need that sort of magic, because you'll be in a position to process the text however you wish before calling insert.

phils
  • 48,657
  • 3
  • 76
  • 115