unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Replacement for C-x 8 based on input methods
@ 2002-05-14 15:17 Kai Großjohann
  2002-05-14 15:38 ` Miles Bader
  0 siblings, 1 reply; 6+ messages in thread
From: Kai Großjohann @ 2002-05-14 15:17 UTC (permalink / raw)


Thanks to Miles Bader I've now got something which can show how the
C-x 8 replacement could in principle work.  Todo:

* Make an input method (or several input methods) which are
  appropriate for this application.  It might be useful to construct
  an input method by computing the union of several other input
  methods (such as latin-1-prefix and latin-1-postfix).

* Put more features in it.  Maybe a prefix arg could ask the user for
  an input method to use for just the next C-x 8 command?

Do you think that this goes in the right direction?

kai
-- 
Silence is foo!

;;; c-x-9.el --- Like C-x 8 but with input method

;; Copyright (C) 2002  Free Software Foundation, Inc.

;; Author: Kai Großjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
;; Keywords: i18n, languages

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:

;; This file is a demonstration of what a replacement of C-x 8 could
;; look like.  It would be more useful if there was an input method
;; especially designed for this.  Thanks a lot to Miles Bader for the
;; meat of the function.

;;; Variables:

(require 'cus-edit)

(defcustom secondary-input-method "latin-1-postfix"
  "For `C-x 9'."
  :group 'mule
  :type '(choice (const nil) string))

;;; Code:

(defun insert-with-secondary-input-method ()
  "Insert a character using the secondary input method."
  (interactive)
  (let ((old-method current-input-method))
    (unwind-protect
	(progn
	  (activate-input-method secondary-input-method)
	  (insert (apply 'string
			 (funcall input-method-function
				  (read-char
				   (format "Insert char using %s: "
					   secondary-input-method))))))
      (if old-method
	  (activate-input-method old-method)
	(inactivate-input-method)))))

(global-set-key (kbd "C-x 9") 'insert-with-secondary-input-method)

(provide 'c-x-9)
;;; c-x-9.el ends here

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

* Re: Replacement for C-x 8 based on input methods
  2002-05-14 15:17 Replacement for C-x 8 based on input methods Kai Großjohann
@ 2002-05-14 15:38 ` Miles Bader
  2002-05-14 16:11   ` Kai Großjohann
  0 siblings, 1 reply; 6+ messages in thread
From: Miles Bader @ 2002-05-14 15:38 UTC (permalink / raw)
  Cc: emacs-devel

A few comments:

. I don't like the prompt -- I like the way the old C-x 8 code doesn't
  show anything in the input area [until the normal time-delayed
  key-echo display shows something -- note that this still happens if
  you use `read-char' without a prompt]

. It's not necessary to say

      (if old-method
	  (activate-input-method old-method)
	(inactivate-input-method)))))

  because `activate-input-method' will do the Right Thing if
  old-method is nil.

. You don't have to convert the character list to a string and then
  insert it -- you can just apply #'insert to the list, because insert
  also works with multiple character arguments...

(sorry if these seem like nit-picking!)

-Miles
-- 
I'm beginning to think that life is just one long Yoko Ono album; no rhyme
or reason, just a lot of incoherent shrieks and then it's over.  --Ian Wolff

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

* Re: Replacement for C-x 8 based on input methods
  2002-05-14 15:38 ` Miles Bader
@ 2002-05-14 16:11   ` Kai Großjohann
  2002-05-14 23:31     ` Miles Bader
                       ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Kai Großjohann @ 2002-05-14 16:11 UTC (permalink / raw)
  Cc: emacs-devel

Miles Bader <miles@gnu.org> writes:

> (sorry if these seem like nit-picking!)

No, you're right about all of them.  I changed the implementation
accordingly.

Now we need the right input method.

My current plan is to take latin-1-prefix and latin-1-postfix and the
current C-x 8 keymap and to construct the union of all the sequences
found there.  (What should I do in case of a conflict?  Prefer the
input methods because these are the new standard?  Or prefer the C-x
8 keymap because that preserves backward compatibility?)

kai
-- 
Silence is foo!

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

* Re: Replacement for C-x 8 based on input methods
  2002-05-14 16:11   ` Kai Großjohann
@ 2002-05-14 23:31     ` Miles Bader
  2002-05-15  1:21     ` Miles Bader
  2002-05-16  7:21     ` Richard Stallman
  2 siblings, 0 replies; 6+ messages in thread
From: Miles Bader @ 2002-05-14 23:31 UTC (permalink / raw)
  Cc: emacs-devel

Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) writes:
> (What should I do in case of a conflict?  Prefer the input methods
> because these are the new standard?  Or prefer the C-x 8 keymap
> because that preserves backward compatibility?)

I'd say just try it and see what the conflicts (if any) are; if
there's not an obvious solution you can always post a query here.

-Miles
-- 
"I distrust a research person who is always obviously busy on a task."
   --Robert Frosch, VP, GM Research

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

* Re: Replacement for C-x 8 based on input methods
  2002-05-14 16:11   ` Kai Großjohann
  2002-05-14 23:31     ` Miles Bader
@ 2002-05-15  1:21     ` Miles Bader
  2002-05-16  7:21     ` Richard Stallman
  2 siblings, 0 replies; 6+ messages in thread
From: Miles Bader @ 2002-05-15  1:21 UTC (permalink / raw)
  Cc: emacs-devel

I think it would also be nice to move the guts of that function into
something like `insert-input-method-char', which takes the input method as
an argument, and then have `insert-with-secondary-input-method' call it.

Then it's easy for people define their own specialized versions (if say
they just really need to insert both latin1 and russian characters
occasionally, but want to use chinese as their default input method).

[I say this, instead of making `insert-with-secondary-input-method' take
an optional argument, because I think the name's not quite right if you do
that -- the term `secondary' is misleading if you're not actually using a
distinguished secondary input method.]

You could even make `insert-input-method-char' be interactive, with the
argument optional and defaulting to `current-input-method'; that way
people could define a prefix to use instead of toggling the input method
on and off (some people may prefer it).

-Miles
-- 
[|nurgle|]  ddt- demonic? so quake will have an evil kinda setting? one that 
            will  make every christian in the world foamm at the mouth? 
[iddt]      nurg, that's the goal 

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

* Re: Replacement for C-x 8 based on input methods
  2002-05-14 16:11   ` Kai Großjohann
  2002-05-14 23:31     ` Miles Bader
  2002-05-15  1:21     ` Miles Bader
@ 2002-05-16  7:21     ` Richard Stallman
  2 siblings, 0 replies; 6+ messages in thread
From: Richard Stallman @ 2002-05-16  7:21 UTC (permalink / raw)
  Cc: miles, emacs-devel

    My current plan is to take latin-1-prefix and latin-1-postfix and the
    current C-x 8 keymap and to construct the union of all the sequences
    found there.

Doing it by hand would be fine if we wanted just one of these.
But we want them for each latin-N alphabet, and maybe more as well.

What we need is a mechanism for defining an input method whose
contents will be computed the first time it is activated.  With that
mechanism, we can define latin-1-bothfix to be computed as the union
of latin-1-prefix and latin-1-postfix.  And likewise for
latin-N-bothfix.

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

end of thread, other threads:[~2002-05-16  7:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-14 15:17 Replacement for C-x 8 based on input methods Kai Großjohann
2002-05-14 15:38 ` Miles Bader
2002-05-14 16:11   ` Kai Großjohann
2002-05-14 23:31     ` Miles Bader
2002-05-15  1:21     ` Miles Bader
2002-05-16  7:21     ` Richard Stallman

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).