🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fj.editor.mule
Article #440

How to grep or mg a japanese character string.

#440
From: KANEMATU Sin'ya
Date: Sat, 04 Jul 1998 00:00
76 lines
4027 bytes
  emacs20.2から、grepやmgを使って漢字の単語などを検索するにはどうすれ
ば良いのでしょうか? grepでeucのfile中の漢字を検索することもできていま
せん。(emacs19.34では問題なくできています。)

  なおmgは、grepのような機能を持つperl scriptで、-j jisなどと指定する
と、jisコードのfile中の漢字を検索することができます。
  mgに呼出しには以下の関数を使っています。
(defun mg (command-args)
  "Run mg instead of grep."
  (require 'compile)
  (interactive
   (list (read-from-minibuffer "Run mg (like this): "
                               "mg -n " nil nil 'grep-history)))
  (compile-internal (concat command-args " " grep-null-device)
                    "No more mg hits" "mg"
                    ;; Give it a simpler regexp to match.
                    nil grep-regexp-alist))

[当方の環境]
emacs-version = "20.2.1"
mule-version = "3.0 (MOMIJINOGA)"
toya31% uname -a
SunOS toya 5.6 Generic sun4m sparc PFU,S-4_20A

  以下は、*scratch* bufferからdescribe-coding-systemをやった結果です。
----- begin of describe-coding-system output -----
Coding system for saving this buffer:
  Not set locally, use the default.
Default coding system (for new files):
  E -- euc-japan (alias of japanese-iso-8bit)
Coding system for keyboard input:
  nil
Coding system for terminal output:
  E -- euc-japan (alias of japanese-iso-8bit)
Defaults for subprocess I/O:
  decoding: E -- euc-japan (alias of japanese-iso-8bit)
  encoding: E -- euc-japan (alias of japanese-iso-8bit)

Priority order for recognizing coding systems when reading files:
  1. iso-2022-7bit
  2. japanese-iso-8bit (alias: euc-jp euc-japan euc-japan-1990)
  3. japanese-shift-jis (alias: sjis shift_jis)
  4. iso-latin-1 (alias: ctext latin-1 iso-8859-1)
  5. iso-2022-7bit-lock (alias: iso-2022-int-1)
  6. emacs-mule
  7. raw-text
  8. chinese-big5 (alias: cn-big5 big5)
  9. no-conversion (alias: binary)

  Other coding systems cannot be distinguished automatically
  from these, and therefore cannot be recognized automatically
  with the present coding system priorities.

  The followings are decoded correctly but recognized as iso-2022-7bit:
    iso-2022-jp

  The followings are decoded correctly but recognized as iso-2022-7bit-lock:
    iso-2022-7bit-ss2 iso-2022-7bit-lock-ss2 chinese-iso-7bit korean-iso-7bit-lock

Particular coding systems specified for certain file names:

  OPERATION	TARGET PATTERN		CODING SYSTEM(s)
  ---------	--------------		----------------
  File I/O      "\\.gz\\(~\\|\\.~[0-9]+~\\)?\\'"(no-conversion . no-conversion)
                "\\.tgz\\'"             (no-conversion . no-conversion)
                "\\.Z\\(~\\|\\.~[0-9]+~\\)?\\'"(no-conversion . no-conversion)
                "\\.elc$"               (no-conversion . no-conversion)
                "\\(\\`\\|/\\)loaddefs.el$"(no-conversion . no-conversion)
                "\\.tar$"               (no-conversion . no-conversion)
                ""                      (undecided)
  Process I/O   "pr-edit"               (junet . junet)
  Network I/O	nothing specified
----- end of describe-coding-system output -----
---
兼松 真哉 (かねまつ しんや)
Technical Details
Message-ID: <yftu34y71ny.fsf@toya.lp.nm.fujitsu.co.jp>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: Japanese,JIS
X-Google-Thread: 10eba4,c25a23c3eaf6c0b7,start
X-Google-Attributes: gid10eba4,public
X-Google-Thread: ff358,c25a23c3eaf6c0b7,start
X-Google-Attributes: gidff358,public
From: KANEMATU Sin'ya <kane@lp.nm.fujitsu.co.jp>
Subject: How to grep or mg a japanese character string.
Date: 1998/07/04
Message-ID: <yftu34y71ny.fsf@toya.lp.nm.fujitsu.co.jp>
X-Deja-AN: 368581867
Content-Type: text/plain; charset=ISO-2022-JP
X-Emacs: Emacs 20.2, MULE 3.0 (MOMIJINOGA)
Organization: MW Div., Fujitsu Ltd., Numazu, Japan.
Mime-Version: 1.0 (generated by SEMI 1.4.4 - "Ecchū-Miyazaki")
Newsgroups: fj.editor.mule,fj.editor.emacs