From: Kenichi Handa <handa@m17n.org>
To: rms@gnu.org
Cc: blais@furius.ca, emacs-devel@gnu.org
Subject: Re: smartquotes.el -- Insertion of unicode quotes in text documents
Date: Tue, 04 Sep 2007 15:48:38 +0900 [thread overview]
Message-ID: <E1ISSDG-0006AH-F8@etlken.m17n.org> (raw)
In-Reply-To: <E1IR12U-0000a1-Fv@fencepost.gnu.org> (message from Richard Stallman on Fri, 31 Aug 2007 03:35:34 -0400)
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)))))
next prev parent reply other threads:[~2007-09-04 6:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1b151690708252221j7177cea1xe8916c52a1110190@mail.gmail.com>
2007-08-26 22:47 ` smartquotes.el -- Insertion of unicode quotes in text documents Richard Stallman
2007-08-27 4:46 ` Martin Blais
[not found] ` <E1IPj9g-0003Zm-8v@fencepost.gnu.org>
2007-08-27 18:53 ` David Kastrup
[not found] ` <E1IQ3Hl-0008FI-LE@fencepost.gnu.org>
2007-08-30 8:12 ` Kenichi Handa
2007-08-30 8:29 ` David Kastrup
2007-08-30 11:46 ` Kenichi Handa
2007-08-30 12:32 ` David Kastrup
2007-08-31 7:36 ` Richard Stallman
2007-08-31 7:35 ` Richard Stallman
2007-09-04 6:48 ` Kenichi Handa [this message]
2007-08-27 5:08 ` David Kastrup
2007-08-27 21:16 ` Composition of Quail IMs (was: smartquotes.el -- Insertion of unicode quotes in text documents) Stefan Monnier
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=E1ISSDG-0006AH-F8@etlken.m17n.org \
--to=handa@m17n.org \
--cc=blais@furius.ca \
--cc=emacs-devel@gnu.org \
--cc=rms@gnu.org \
/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.