emacs-devel
[Top][All Lists]
Advanced

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

Replacement for C-x 8 based on input methods


From: Kai Großjohann
Subject: Replacement for C-x 8 based on input methods
Date: Tue, 14 May 2002 17:17:38 +0200
User-agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.2.50 (i686-pc-linux-gnu)

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 <address@hidden>
;; 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



reply via email to

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