unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* read key sequence according to input method?
@ 2002-05-14  9:18 Kai Großjohann
  2002-05-14  9:55 ` Miles Bader
  0 siblings, 1 reply; 4+ messages in thread
From: Kai Großjohann @ 2002-05-14  9:18 UTC (permalink / raw)


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.

kai
-- 
Silence is foo!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: read key sequence according to input method?
  2002-05-14  9:18 read key sequence according to input method? Kai Großjohann
@ 2002-05-14  9:55 ` Miles Bader
  2002-05-14 15:11   ` Kai Großjohann
  0 siblings, 1 reply; 4+ messages in thread
From: Miles Bader @ 2002-05-14  9:55 UTC (permalink / raw)
  Cc: emacs-devel

Kai.Grossjohann@CS.Uni-Dortmund.DE (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]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: read key sequence according to input method?
  2002-05-14  9:55 ` Miles Bader
@ 2002-05-14 15:11   ` Kai Großjohann
  2002-05-14 15:25     ` Miles Bader
  0 siblings, 1 reply; 4+ messages in thread
From: Kai Großjohann @ 2002-05-14 15:11 UTC (permalink / raw)
  Cc: emacs-devel

Miles Bader <miles@lsi.nec.co.jp> writes:

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

Yes, this looks quite nice.  Thanks a lot!  I'll continue that other
thread about replacing C-x 8 with something based on your suggestion.

kai
-- 
Silence is foo!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: read key sequence according to input method?
  2002-05-14 15:11   ` Kai Großjohann
@ 2002-05-14 15:25     ` Miles Bader
  0 siblings, 0 replies; 4+ messages in thread
From: Miles Bader @ 2002-05-14 15:25 UTC (permalink / raw)
  Cc: emacs-devel

Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) writes:
> Yes, this looks quite nice.  Thanks a lot!  I'll continue that other
> thread about replacing C-x 8 with something based on your suggestion.

Ah, so that's what you want it for...

I think that's even simpler; the following seems to actually work pretty
well (though no doubt there are corner cases that need addressing):

(defun insert-latin1-character ()
  (interactive)
  (let ((prev-input-method current-input-method))
    (unwind-protect
	(progn
	  (activate-input-method 'latin-1-prefix)
	  (apply #'insert (funcall input-method-function (read-event))))
      (activate-input-method prev-input-method))))

One nice thing about the old implementation, though, is that you can get
help by typing `C-h' during input...

-Miles
-- 
A zen-buddhist walked into a pizza shop and
said, "Make me one with everything."

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-05-14 15:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-14  9:18 read key sequence according to input method? Kai Großjohann
2002-05-14  9:55 ` Miles Bader
2002-05-14 15:11   ` Kai Großjohann
2002-05-14 15:25     ` Miles Bader

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).