all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kenichi Handa <handa@m17n.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: juri@jurta.org, tzz@lifelogs.com, emacs-devel@gnu.org
Subject: Re: adding consistent extra symbols to input methods (cyrillic-*, croatian-*, slov*, czech-* etc.) input methods
Date: Mon, 07 Jul 2008 14:25:02 +0900	[thread overview]
Message-ID: <E1KFjDi-0002gM-Td@etlken.m17n.org> (raw)
In-Reply-To: <jwvzlouwbof.fsf-monnier+emacs@gnu.org> (message from Stefan Monnier on Mon, 07 Jul 2008 00:39:34 -0400)

In article <jwvzlouwbof.fsf-monnier+emacs@gnu.org>, Stefan Monnier <monnier@iro.umontreal.ca> writes:

> > I remember that activating multiple input methods was
> > discussed a while ago on this list, but don't remember the
> > conclusion.

> :-(  My memory was telling me that you had implemented and installed
> it already.

Ah!!!  Now I remembered that I wrote a experimental code in
a little bit tricky way.  I dig out the attached mail.  But,
I completely forgot about it because there was no response
at that time.

---
Kenichi Handa
handa@ni.aist.go.jp

------------------------------------------------------------
From: Kenichi Handa <handa@m17n.org>
To: rms@gnu.org
In-reply-to: <E1IR12U-0000a1-Fv@fencepost.gnu.org> (message from Richard	Stallman on Fri, 31 Aug 2007 03:35:34 -0400)
MIME-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya")
Content-Type: text/plain; charset=US-ASCII
Date: Tue, 04 Sep 2007 15:48:38 +0900
Cc: blais@furius.ca, emacs-devel@gnu.org
Subject: Re: smartquotes.el -- Insertion of unicode quotes in text documents

In article <E1IR12U-0000a1-Fv@fencepost.gnu.org>, Richard Stallman <rms@gnu.org> writes:

>     What kind of user interface should be provided for
>     activating and deactivating multiple input methods?

> Here's one idea: the user enables and disables one input method,
> directly, and the others are enabled or disabled by a Lisp interface.
> That Lisp interface can be called by other commands.

> Does this solve that one problem?

Yes.  I implemented it as an add-on code (with a little bit
tricky way).  Once it is found that it works well, I'll
merge the code into mule-cmds.el while cleaning the code.

Please try the attached code with the latest
emacs-unicode-2.  The Lisp interfaces are the functions
activate-preposition-input-method and
inactivate-preposition-input-method.

---
Kenichi Handa
handa@m17n.org

(defvar local-input-method-list nil
  "List of local preposition input methods.")
(make-variable-buffer-local 'local-input-method-list)
(defvar global-input-method-list nil
  "List of global preposition input methods.")
(defvar normal-input-method nil
  "Currently active normal (i.e. non-preposion) input method.")

(defun multi-input-method-function (event)
  "Input method function used while some preposition input method is active."
  (let ((disable-input-method-hook t)
	unread-command-events)
    (dolist (elt (append global-input-method-list
			 local-input-method-list))
      (let (input-method-history default-input-method)
	(activate-input-method elt)
	(setq unread-command-events
	      (nreverse (funcall input-method-function event)))
	(setq event (car unread-command-events)
	      unread-command-events (cdr unread-command-events))))
    (let (input-method-history)
      (inactivate-input-method))
    (setq current-input-method nil
	  current-input-method-title nil)
    (unwind-protect
	(if normal-input-method
	    (progn
	      (activate-input-method normal-input-method)
	      (append (funcall input-method-function event)
		      unread-command-events))
	  (cons event unread-command-events))
      (setq input-method-function 'multi-input-method-function))))

;; If non-nil, disable input-method-hook.
(defvar disable-input-method-hook nil)

;; A function for input-method-active-hook used while some preposition
;; input method is active.
(defun input-method-activate-hook ()
  (unless disable-input-method-hook
    (setq normal-input-method current-input-method)
    (if (or local-input-method-list global-input-method-list)
	(setq input-method-function 'multi-input-method-function))))
	      
;; A function for input-method-inactivate-hook used while some
;; preposition input method is active.
(defun input-method-inactivate-hook ()
  (unless disable-input-method-hook
    (setq normal-input-method nil)
    (if (or local-input-method-list global-input-method-list)
	(setq input-method-function 'multi-input-method-function))))

(defun activate-preposition-input-method (input-method global)
  "Activate a preposition INPUT-METHOD.
INPUT-METHOD is handled before a normal input method.
If the second arg GLOBAL is non-nil, activate it for all buffers.
Otherwise, activate it only for the current buffer."
  (if (and input-method (symbolp input-method))
      (setq input-method (symbol-name input-method)))
  (or (assoc input-method input-method-alist)
      (error "Unknown input method: %s" input-method))
  (unless (assoc-string input-method 
			(if global global-input-method-list
			  local-input-method-list))
    (or global-input-method-list
	local-input-method-list
	(progn
	  (add-hook 'input-method-activate-hook
		    'input-method-activate-hook)
	  (add-hook 'input-method-inactivate-hook
		    'input-method-inactivate-hook)))
    (setq normal-input-method current-input-method)
    (if global
	(progn
	  (push input-method global-input-method-list)
	  (setq-default input-method-function 'multi-input-method-function))
      (push input-method local-input-method-list))
    (make-local-variable 'input-method-function)
    (setq input-method-function 'multi-input-method-function)))

(defun inactivate-preposition-input-method (input-method global)
  "Inactivate a proposition INPUT-METHOD.
If the second arg GLOBAL is non-nil, inactivate it for all buffers.
Otherwise, inactivate it only for the curren buffer."
  (if (and input-method (symbolp input-method))
      (setq input-method (symbol-name input-method)))
  (if global
      (setq global-input-method-list
	    (delete input-method global-input-method-list))
    (setq local-input-method-list
	  (delete input-method local-input-method-list)))
  (or global-input-method-list
      local-input-method-list
      (progn
	(remove-hook 'input-method-activate-hook
		     'input-method-activate-hook)
	(remove-hook 'input-method-inactivate-hook
		     'input-method-inactivate-hook)
	(setq input-method-function nil)
	(when normal-input-method
	  (inactivate-input-method)
	  (activate-input-method normal-input-method)))))

  reply	other threads:[~2008-07-07  5:25 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-13 14:27 composed characters question and suggestions for quail-cyrillic-* Ted Zlatanov
2008-06-13 15:11 ` Eli Zaretskii
2008-06-13 15:56 ` Jason Rumney
2008-06-13 18:09   ` Ted Zlatanov
2008-06-14  9:44     ` Eli Zaretskii
2008-06-14 18:55       ` Stephen J. Turnbull
2008-06-14 19:45         ` Eli Zaretskii
2008-06-18 20:17           ` Ted Zlatanov
2008-06-19 11:45             ` Kenichi Handa
2008-07-02 20:25               ` Ted Zlatanov
2008-07-03  2:29                 ` Kenichi Handa
2008-07-03 19:53                   ` adding consistent extra symbols to input methods (cyrillic-*, croatian-*, slov*, czech-* etc.) input methods Ted Zlatanov
2008-07-05 12:54                     ` Kenichi Handa
2008-07-06 18:40                       ` Juri Linkov
2008-07-06 22:54                         ` Miles Bader
2008-07-10  0:09                           ` Juri Linkov
2008-07-10  0:37                             ` Kenichi Handa
2008-07-10  0:52                               ` Juri Linkov
2008-07-10  1:44                                 ` Kenichi Handa
2008-07-10  1:15                             ` Stefan Monnier
2008-07-10  0:27                           ` Juri Linkov
2008-07-10  1:16                             ` Miles Bader
2008-07-10 18:43                               ` Juri Linkov
2008-07-11  2:52                                 ` Miles Bader
2008-07-07  1:57                         ` Kenichi Handa
2008-07-07  4:39                           ` Stefan Monnier
2008-07-07  5:25                             ` Kenichi Handa [this message]
2008-07-07 19:42                               ` Ted Zlatanov
2008-07-07 22:05                               ` Juri Linkov
2008-07-13  5:11                                 ` Eli Zaretskii
2008-07-13  5:17                                   ` Miles Bader
2008-07-13 21:27                                     ` Juri Linkov
2008-07-14  3:18                                       ` Miles Bader
2008-07-14  4:43                                         ` Kenichi Handa
2008-07-14 21:51                                           ` Juri Linkov
2008-07-15  1:24                                             ` Kenichi Handa
2008-07-28 13:30                                               ` multiple input methods (was: adding consistent extra symbols to input methods) Juri Linkov
2008-07-06 18:41     ` composed characters question and suggestions for quail-cyrillic-* Juri Linkov
2008-07-07 20:12       ` Ted Zlatanov
2008-07-07 21:42         ` Juri Linkov
2008-07-08  0:48           ` Kenichi Handa
2008-07-08 10:46           ` Werner LEMBERG
2008-07-08 21:47             ` David Kastrup
2008-07-08 15:37           ` Ted Zlatanov
2008-07-08 17:38             ` James Cloos
2008-07-08 22:54             ` Juri Linkov
2008-07-09 16:02               ` Ted Zlatanov
2008-07-09 18:02                 ` James Cloos
2008-07-09 18:49                   ` Ted Zlatanov
2008-07-09 19:51                   ` Juri Linkov
2008-07-09 18:48                 ` Ted Zlatanov
2008-07-09 19:33                   ` Juri Linkov
2008-07-09 22:14                     ` Ted Zlatanov
2008-07-09 23:52                       ` Juri Linkov
2008-07-10 12:47                         ` Ted Zlatanov
2008-07-10 18:45                           ` Juri Linkov
2008-07-10 19:10                             ` Ted Zlatanov
2008-07-10 19:52                               ` Juri Linkov
2008-07-10 20:40                                 ` Ted Zlatanov
2008-07-10 22:01                                   ` Juri Linkov
2008-07-12 20:51                                     ` Juri Linkov
2008-07-14 14:01                                     ` Ted Zlatanov
2008-07-14 21:47                                       ` Juri Linkov
2008-07-15 15:06                                         ` Ted Zlatanov
2008-07-15 20:32                                           ` Juri Linkov
2008-08-01 21:07                                             ` Ted Zlatanov
2008-08-05 21:00                                             ` Ted Zlatanov
2008-08-05 22:05                                               ` Chong Yidong
2008-07-10 22:09                                 ` Stefan Monnier
2008-07-10 22:54                                   ` Juri Linkov
2008-07-11  1:26                                     ` Stefan Monnier
2008-07-11  2:08                                     ` Kenichi Handa
2008-07-09 19:21                 ` Juri Linkov
2008-07-08 15:49           ` James Cloos
2008-07-08 18:50             ` Ted Zlatanov
2008-07-08 19:50               ` James Cloos
2008-07-08 20:26                 ` composed characters question and suggestions for?quail-cyrillic-* Teemu Likonen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1KFjDi-0002gM-Td@etlken.m17n.org \
    --to=handa@m17n.org \
    --cc=emacs-devel@gnu.org \
    --cc=juri@jurta.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=tzz@lifelogs.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.