That's how emacs stored the definition of the macro: I defined the macro
with C-x ( O M C-x ), named it with C-x C-k n om RET and inserted it in
the buffer with M-x insert-kbd-macro RET om RET. The result was as shown
above.
> I can get the following to work
>
> (defun om (&optional arg)
> "Keyboard macro."
> (interactive "p")
> (kmacro-exec-ring-item '([79 77 return] 0 "%d") arg))
>
> so assuming its just a stylistic question. [If not please enlighten]
In some sense, fset is the lower level primitive: defun could be defined
in terms of fset (but not the other way round). But they do roughly the
"same thing": they attach a function to the function cell of a symbol.
> By 'work' I mean after this definition, M-x om inserts ॐ into the buffer if devanagari-itrans is
> active. So far so good
>
> After that I am a bit stuck:
> 2. kmacro-exec-ring-item has just this much documentation.
>
> kmacro-exec-ring-item is a compiled Lisp function in `kmacro.el'.
>
> (kmacro-exec-ring-item ITEM ARG)
>
> Execute item ITEM from the macro ring.
>
> Does not take me far :-(
>
Can't help here.
> 3. I guess this is really the same as the above question...
> You say
>
>
> So all you need to do is produce that vector of ascii values in there. I
> wrote a trivial python program to produce the ascii codes of your text
> and stuffed the output into the vector, reevaluated the fset, and
> executed the macro with a result that looks suspiciously like the one in
> your email.
>
> The python (or elisp) to a text (ASCII-only) string to its ASCII is 1 line:
>
> >>> def Ascii(str): return [ord(c) for c in str]
>
> I ran this on my file and got:
> [79, 77, 32, 98, 104, 85, 114, 98, 104, 117, 118, 97, 72, 32, 115, 117, 118, 97, 72, 10, 116, 97,
> 116, 115, 97, 118, 105, 116, 117, 114, 118, 97, 114, 101, 110, 121, 97, 109, 10, 98, 104, 97, 114,
> 103, 111, 32, 100, 101, 118, 97, 115, 121, 97, 32, 100, 104, 73, 109, 97, 104, 105, 10, 100, 104,
> 105, 121, 111, 32, 121, 111, 110, 97, 72, 32, 112, 114, 97, 99, 104, 111, 100, 97, 121, 65, 116, 10]
>
> Ok so remove the commas, ADD A 'return' after to last 10 (Whats that??)
The 10 is a RET, so you shouldn't have to add an extra one.
> And it almost works
> ie I get the devanagari output followed by a elisp error:
>
> Debugger entered--Lisp error: (void-variable प्रचोदयात्)
> eval(प्रचोदयात्)
> eval-last-sexp-1(t)
> eval-last-sexp(t)
> eval-print-last-sexp()
> call-interactively(eval-print-last-sexp nil nil)
> execute-kbd-macro([79 77 32 98 104 85 114 98 104 117 118 97 72 32 115 117 118 97 72 116 97 116 115
> 97 118 105 116 117 114 118 97 114 101 110 121 97 109 98 104 97 114 103 111 32 100 101 118 97 115 121
> ...] 1 kmacro-loop-setup-function)
> kmacro-exec-ring-item(([79 77 32 98 104 85 114 98 104 117 118 97 72 32 115 117 118 97 72 116 97
> 116 115 97 118 105 116 117 114 118 97 114 101 110 121 97 109 98 104 97 114 103 111 32 100 101 118 97
> 115 121 ...] 0 "%d") 1)
> om(1)
> call-interactively(om t nil)
> execute-extended-command(nil)
> call-interactively(execute-extended-command nil nil)
>
> The प्रचोदयात् is the devanagari of the last line: prachodayAt
> If I remove the 10 (newline?) it seems to work without the elisp error
>
As you point out in your subsequent post, that's an artifact of lisp-interaction
mode: it does not happen in a text file.
> I guess the problem would be solved if some more suitable function than
> I wonder if there is some better function than kmacro-exec-ring-item could be found for this?
>
And you seem to have found one of those as well.
Good luck!
Nick