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

Re: incremental searchと日本語<Re: Emacspeakでのウインドー状況理解



坂本です。

>>>>> In [bep] 
>>>>>	Reiko TAKAHASHI (高橋玲子) <HFC03614@...> wrote:

> incremental searchに関してなのですが、これで日本語の検索はできないのでしょ
> うか? 私のところではできないみたいなんですが・・・。

標準のMeadowでは、多分できません。

で、添付の.elファイルを/usr/local/share/Meadow/site-lisp/の下に置いて

(require 'ekb-isearch)
と.emacsに書いてください。これでできるようになると思います。
詳しくは多分、
http://www.nanap.org/
以下のページ軍を読んでみてください。
;; ekb-isearch.el --- Enable encoded-kbd in incremental search miner mode.

;; Copyright (C) 2000  Keiichi Suzuki

;; Author: Keiichi Suzuki <keiichi@...>
;; Keywords: isearch, mw32, ime
;; Version: 0.3

;; This file is NOT part of GNU Emacs.

;; This program 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 of the License, or
;; (at your option) any later version.

;; This program 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 this program; if not, write to the Free Software
;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

;;; Commentary:

;; For programed use of encoded keyboard in isearch-mode.
;; Only supported japanese-shift-jis, currently.

;;; Install:

;; Install this file to appropriate directory with associated by load-path.
;; And put these lines into your ~/.emacs.

;;	(require 'ekb-isearch)

;;; History:
;; Jan 14 2000	Version 0.3 released.
;;	Fix typo.
;; Jan 10 2000	Version 0.2 released.
;;	Rename the verbose name.
;;	Suport iso-2022-8bit and big5.
;; Jan 09 2000	Version 0.1 released.

;;; Code:

(defvar ekb-isearch-mode nil
  "Non-nil if in Ekb-Isearch minor mode.")
(put 'ekb-isearch-mode 'permanent-local t)

(or (assq 'ekb-isearch-mode minor-mode-alist)
    (setq minor-mode-alist
	  (cons '(ekb-isearch-mode " Ekb-Isearch") minor-mode-alist)))

(defvar ekb-isearch-mode-map
  (let ((map (copy-keymap isearch-mode-map))
	(i 128))
    (while (< i 256)
      (define-key map (vector i) 'ekb-isearch-handle-8bit)
      (setq i (1+ i)))
    map)
  "Keymap for Ekb-Isearch minor mode.")

(or (assq 'ekb-isearch-mode minor-mode-map-alist)
    (setq minor-mode-map-alist
	  (cons (cons 'ekb-isearch-mode ekb-isearch-mode-map)
		minor-mode-map-alist)))
		       
(defun ekb-isearch-handle-8bit ()
  "Handle an 8-bit character entered in Encoded-kbd isearch mode."
  (interactive)
  (cond ((eq encoded-kbd-coding 'iso2022-7)
	 (error "Can't handle the character code %d" last-command-char))

	((eq encoded-kbd-coding 'iso2022-8)
	 (cond ((= last-command-char ?\216)
		(aset encoded-kbd-iso2022-invocations 2 2))
	       ((= last-command-char ?\217)
		(aset encoded-kbd-iso2022-invocations 2 3))
	       ((>= last-command-char ?\240)
		(ekb-isearch-printing-char-iso2022-8bit))
	       (t
		(error "Can't handle the character code %d"
		       last-command-char))))

	((eq encoded-kbd-coding 'sjis)
	 (ekb-isearch-printing-char-sjis))

	(t
	 (ekb-isearch-printing-char-big5))))

(defun ekb-isearch-printing-char-iso2022-8bit ()
  (interactive)
  (let* ((charset (aref encoded-kbd-iso2022-designations
			(or (aref encoded-kbd-iso2022-invocations 2)
			    (aref encoded-kbd-iso2022-invocations 1))))
	 (last-command-char
	  (if (= (charset-dimension charset) 1)
	      (make-char charset last-command-char)
	    (make-char charset last-command-char (read-char-exclusive)))))
    (aset encoded-kbd-iso2022-invocations 2 nil)
    (isearch-process-search-char last-command-char)))

(defun ekb-isearch-printing-char-sjis ()
  (interactive)
  (let ((last-command-char
         (if (or (< last-command-char ?\xA0) (>= last-command-char ?\xE0))
             (decode-sjis-char (+ (ash last-command-char 8)
                                  (read-char-exclusive)))
           (make-char 'katakana-jisx0201 last-command-char))))
    (message "Last-Command-Char %s" last-command-char)
    (isearch-process-search-char last-command-char)))

(defun ekb-isearch-printing-char-big5 ()
  (interactive)
  (let ((last-command-char
	 (decode-big5-char (+ (ash last-command-char 8)
			      (read-char-exclusive)))))
    (isearch-process-search-char last-command-char)))

(defun ekb-isearch-refresh-message ()
  (interactive)
  (isearch-message))

;;;###autoload
(defun ekb-isearch-mode (&optional arg)
  "Toggle Ekb-Isearch minor mode, if possible.
With arg, turn Ekb-Isearch mode on if and only if arg is positive."
  (if (and (or isearch-mode ekb-isearch-mode)
	   (or (null arg)
	       (> (prefix-numeric-value arg) 0)))
      (if encoded-kbd-mode
	  (setq overriding-terminal-local-map ekb-isearch-mode-map
		isearch-mode nil
		ekb-isearch-mode t)
	(setq overriding-terminal-local-map isearch-mode-map
	      isearch-mode " Isearch"
	      ekb-isearch-mode nil))
    (setq ekb-isearch-mode nil))
  (and ekb-isearch-mode
       (run-hooks 'ekb-isearch-mode-hook)))

(defun ekb-isearch-end ()
  (ekb-isearch-mode 0))

(defun ekb-isearch-start ()
  (ekb-isearch-mode 1))

(add-hook 'isearch-mode-end-hook 'ekb-isearch-end)
(add-hook 'isearch-mode-hook 'ekb-isearch-start)
(defadvice encoded-kbd-mode (after sync-ekb-isearch-mode activate)
  "Sync Ekb-Isearch-Mode withc Encoded Keyboard mode."
  (ekb-isearch-mode nil))

;;; For Meadow.

(defun ekb-isearch-mw32-ime-toggle ()
  (interactive)
  (mw32-ime-toggle)
  (isearch-message))

(when (fboundp 'mw32-ime-toggle)
  (define-key ekb-isearch-mode-map [kanji] 'ekb-isearch-mw32-ime-toggle)
  (define-key ekb-isearch-mode-map [compend] 'ekb-isearch-refresh-message)
  (define-key isearch-mode-map [kanji] 'ekb-isearch-mw32-ime-toggle)
  (define-key isearch-mode-map [compend] 'ekb-isearch-refresh-message))

(provide 'ekb-isearch)

;;; ekb-isearch.el ends here