emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: read key sequence according to input method?


From: Miles Bader
Subject: Re: read key sequence according to input method?
Date: 14 May 2002 18:55:44 +0900

address@hidden (Kai Großjohann) writes:
> How can I read a key sequence according to some input method?  The
> read-key-sequence function appears to work according to keymaps, but
> input methods don't define keymaps, I think.

Hmmm.. I looked around, and couldn't find anything obvious, so I consed
up the following; is this the sort of thing you want?

(defun read-input-method-key-sequence (prompt &optional input-method)
  "Read one or more characters using an input method and return as a vector.
This returns a vector of one character unless the input method returns more.

First arg PROMPT is a prompt string.  If nil, do not prompt specially.
Second arg INPUT-METHOD is the input method to use; if nil, use the
current buffer's active input from `current-input-method'."
  (unless input-method
    (setq input-method current-input-method))
  (let ((cursor-in-echo-area prompt)
        (input-method-use-echo-area prompt))
    (when prompt
      (message prompt))
    (if input-method
        (let ((prev-input-method current-input-method))
          (unwind-protect
              (progn
                (activate-input-method input-method)
                (apply #'vector (funcall input-method-function (read-event))))
            (activate-input-method prev-input-method)))
      (vector (read-event)))))

-Miles
-- 
`...the Soviet Union was sliding in to an economic collapse so comprehensive
 that in the end its factories produced not goods but bads: finished products
 less valuable than the raw materials they were made from.'  [The Economist]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]