LinuxDoc+Emacs+Ispell-HOWTO Author: Philippe MARTIN () &nl; Translator: Sébastien Blondeel () v0.4, 27 February 1998 早川 仁 () v0.00, 1999年 2月27日 このドキュメントは Linux HOWTO、もしくは他の Linux Documentation Project の ドキュメントの著者及び翻訳者を対象としています。この文章の目的は そのような方達に、Emacs や Ispell などと言ったツールの使い方のヒントを 与えることです。 (訳注: 原文では "Emacs 上" という意味を表す場合に、under Emacs や upon Emacs と表記が統一されていませんが意味が同じ場合、訳はすべて "Emacs 上" に統一してあります。またこの文書はもともとフランス語で 書かれ、それを英語に翻訳した物をさらに日本語に翻訳したものです。 ですから、欧文フォント(ISO-8859-1)が含まれていましたが、recode という ソフトで "recode latin1:texte ファイル名" と指定して疑似表現に変換を しています。(例: cafe' など)なおこのソフトのソース自体は などから 入手することができます) 序文 Copyright

Copyright Philippe Martin 1998&nl; You may redistribute and/or modify this document as long as you comply with the terms of the GNU General Public Licence, version 2 or later. このドキュメントは GNU General Public Licnce(GPL) Version 2 以降に 従う限り再配布や修正を行ってもかまいません。 クレジット

Se'bastien Blondeelに感謝します。彼は意地悪で、何度も Emacs の セットアップについて質問してきました。彼のするどい質問によって Emacs についてより知る事ができ、そしてその知識はこのドキュメントと してあなたに伝える事ができます。 コメント

このドキュメントをより良くするための物であれば、どんなことでも私に聞い てください。あなたの意見全てに目を通します。同じくこのドキュメントの トピックについての質問にも躊躇しないでください。このドキュメントをより 良くするための質問に答える事は嬉しい事です。 (フランス語から英語の翻訳者注:英語に自信が無ければ、私に送ってください!) (英語から日本語の翻訳者注:英語に自信が無くても、私に送らないで下さい :) Versions

この文書は以下のバージョンのソフトを対象としています。 Sgml-tools version 0.99, Emacs version 19.34, Ispell version 3.1, この文書の中で参照されている全ての Emacs ライブラリは、新しいバージョンの Emacs と一緒に配布されているものです。ただし、XEmacs と一緒に配布されている iso-sgml 及び単体のライブラリーである psgml は除きます。 (訳注: 訳者である私自身は、Windows NT Ver.4.0 上の Mule for Win 32 Version 1.22 (紅葉) (Emacs version 19.28.31ベース)で確認しましたが、 他のバージョンでも(必要なフォント等をお持ちな限り)特に問題は無いかと 思われます。Emacs 自体について書かれている場所では、可能な限り Mule でも 確認して補足してあります) イントロダクション SGML

SGML(Standard Generalised Mark-up Language) は 文書の型を定義する言語です。

例えば文書の型をレシピと定義すると、一番目の部分で材料、二番目で付属品、 三番目でケーキの焼き方の手順を、そして最後に素敵な絵で出来上がりを示します。

これは文書型定義(Document Type Definition 又はDTD)と 呼ばれます。これは最終的にどのように見えるかと言うことを定義するのではなく、 何を含んでいるかということだけを表現します。

同じ例をもう一度使ってみましょう。私のレシピのアイデアを読むと、あなたは 自分が書いたレシピやあなたの好きな料理とそっくり、あるいはアイデアを盗用 されたと思うかもしれませんが、実際には私のアイデアとあなたのアイデアは違っ たことから思いついたものです。私のレシピは浴室の戸棚の左上のすみっこを見 ていて思いついたもので、材料は、プールとバーベキュー調理台の間にある裏庭 を歩いている時にみつけたものです。あなたの場合はどうでしょうか?

標準化定義(SGML)によって、最終的に読者にどのように見えるかということを意識 せずにドキュメントを書くことができます。 LinuxDoc 型定義

この型はあなたの想像通り、Linux に関係するドキュメントを書くために 使用されます。

そのようなドキュメントは通常以下のように構成されます。−タイトルで 始まり、著者名、(翻訳者名)、バージョン、そして日付です。 次に概要(ですから、自分が探している情報が含まれているかどうかを判断す る為にすべてを読む必要はありません)それから目次が来ますので、急いでい る場合には直接読みたい部分へと飛べます。

つぎに章、節(セクション)、段落(パラグラフ)のリストが来ます。これら の中にプログラムやリストの挿入を行ったり、フォントを変更して単語や文 (センテンス)を強調したり、ドキュメント中の他の部分を参照する事などが 可能です。

そのようなドキュメントを書く為に必要なのは単に、タイトル、著者名、日付、 ドキュメントのバージョン、章、節などを正しく指定することとその要素は 何であるかといった事です。 SGML-Tools

SGML-Tools は、ドキュメント内の指示(タグ)をあなたが目的とする最終的な 形に変換するものです。もしあなたがそのドキュメントを個人用のライブラリ とするのであれば、PostScript を選択するでしょうし、世界中と Web で共有 したいのであれば HTML になるでしょう。もし Windows 上でも読まなければ ならないのであれば(どうしてもそうしたいのであれば)RTF 形式に変換して、 どんなワープロソフトからでも読めるようにすることもできますし、もしくは 気分を変えるために上記の3つのフォーマットすべてを使うこともあるでしょう。 SGML-Toolは anonymous FTP で より入手できます。 はじめてのドキュメント

テキスト形式のドキュメント

テキスト形式のドキュメントを、(他のフォーマットにする為に)SGML 形式に 変換したい場合、このように行います。 先頭に次のような行を追加します。

ここにタイトルを入れます&etago;title> <author>著者名、著者のe-maiアドレスなどです&etago;author> <date>バージョンと日付です&etago;date> </verb> <item> <!-- If you describe briefly the contents of the document in the beginning, surround that paragraph with the <tt><abstract></tt> and <tt>&etago;abstract></tt> tags. --> ドキュメントの概要を書く場合、そのパラグラフを <tt><abstract></tt> と <tt>&etago;abstract></tt> タグで囲んでください。 <item> <!-- Then insert the <tt><toc></tt> tag, which stands for <em>Table Of Contents</em>. --> それから <tt><toc></tt> タグを挿入して下さい。これは <em>Table Of Contents</em>(目次)の略です。 <item> <!-- At the beginning of each new chapter, replace the line giving the number and title of the chapter with: --> 各章の始めの、章の番号及びタイトルをこのように置き換えてください。 <!-- <verb> <sect>The Title Of The Chapter </verb> --> <verb> <sect>章のタイトル </verb> そして、<tt>&etago;sect></tt> タグを章の最後に追加して下さい。 <!-- and add the <tt>&etago;sect></tt> tag at the end of the chapter.&nl; --> <p> <!-- <bf>Note :</bf> You don't have to put the chapter number, this is done automatically. --> <bf>注意:</bf>自動的に行われますので、章番号を付ける必要はありません。 <item> <!-- Proceed in the same way for sections. You need to delete their numbers and tag their titles with <tt><sect1></tt> and they end with <tt>&etago;sect1></tt>. --> セクションについても、同様に行ってください。番号を削除して、 タイトルを <tt><sect1></tt> と <tt>&etago;sect1></tt> で タグ付けする必要があります。 <item> <!-- You can also define as many as 4 levels of nesting in the sections, using <tt><sectn></tt> and <tt>&etago;sectn></tt> where <tt>n=</tt> 2, 3, or 4 in a similar way. --> 同じく <tt><sectn></tt> と <tt>&etago;sectn></tt> (<tt>n=</tt>2,3,4) を 使う事によって、セクション内で4レベルのネストを定義出来ます。 <item> <!-- In the beginning of each paragraph, insert the <tt><p></tt> tag. --> 各パラグラフの始めには、<tt><p></tt> タグを挿入して下さい。 <item> <!-- If you need to emphasise some parts, tag them with <tt><it></tt> and <tt>&etago;it></tt> (<it>italics</it>), <tt><bf></tt> and <tt>&etago;bf></tt> (<bf>bold face</bf>), or <tt><tt></tt> and <tt>&etago;tt></tt> (<tt>typewriter style</tt>). --> 強調したい部分には、 <tt><it></tt> と <tt>&etago;it></tt>(イタリック)、 <tt><bf></tt> と <tt>&etago;bf></tt>(ボールド)、 <tt><tt></tt> と <tt>&etago;tt></tt>(タイプライタースタイル) といったタグを使って下さい。 <item> <!-- To insert a list like the following one: --> リストを挿入するためには、このようにします。 <!-- <verb> This is a four lines list: - first line goes here - second line comes next - yet another one - that's it. </verb> --> <verb> これは4行のリストです: - ここは1行目です - 2行目です - 3行目です - 最後の行です </verb> <!-- you must replace it with: --> これはこのように表示します。 <!-- <verb> This is a four lines list: <itemize> <item>first line goes here <item>second line come next <item>yet another one <item>that's it. &etago;itemize> </verb> --> <verb> これは4行のリストです: <itemize> <item>ここは1行目です <item>2行目です <item>3行目です <item>最後の行です &etago;itemize> </verb> <item> <!-- When a whole block is a part of a program, or something else that needs to stick out: --> ブロック内全てがプログラム(の一部)、もしくは目立たせる必要がある場合は、 <!-- <verb> <verb> 10 REM Oh my God what's this? 20 REM I thought this had long disappeared! 30 PRINT "I am back to"; 40 PRINT "save the world." 50 INPUT "From whom, do you reckon? ",M$ 60 IF M$="Bill" THEN PRINT "Thou art wise.":GOTO PARADISE 70 ELSE PRINT "You ain't got a clue...":GOTO RICHMOND &etago;verb> --> <verb> <verb> 10 REM おぉ神よ、この言語はいったい何なんでしょうか? 20 REM 永く失われし物のように見受けられますが 30 PRINT "私は戻ってきた"; 40 PRINT "世界を救う為に。" 50 INPUT "あなたはその時誰を頼りますか? ",M$ 60 IF M$="Bill" THEN PRINT "汝は賢人である。":GOTO PARADISE 70 ELSE PRINT "汝は何も分かっておらぬ…":GOTO RICHMOND &etago;verb> </verb> <item> <!-- Thus far, your SGML formating skills are fairly decent. If you want to refine your document, you may have a look at the user's guide for <bf>SGML-Tools</bf>, which gives more details about the <bf>LinuxDoc</bf> document type. --> これまでの所で、あなたの SGML フォーマットにするスキルは見違えるように 向上しました。もしもあなたのドキュメントに磨きをかけたいのでしたら、 User's guide for <bf>SGML-Tools</bf> を参照してください。 <bf>LinuxDoc</bf> ドキュメント型について、より詳しく書かれています。 </enum> </sect1> </sect> <sect> Emacs の設定 <!-- Configuring <tt>Emacs</tt>--> <p> <sect1> アクセント付きの文字 <!-- Accented Characters --> <p> <!-- If you want to write documents in French or in any other western European language, you will need 8-bit characters. This is how to set Emacs up to tell it to accept such characters. --> もしドキュメントをフランス語や他の西ヨーロッパの言語で書きたい場合、 8-bit 文字が必要になります。ここではそのような文字を扱うには どのように Emacs をセットアップするかについて説明します。 <sect2> 8-bit 文字の表示 <!-- The displaying of 8-bit characters --> <p> <!-- To let Emacs display 8-bit characters, you will need the following lines in your <tt>.emacs</tt> file: --> <tt>Emacs</tt> に 8-bit 文字を表示させるためには、以下のような行が .emacs ファイルの中に必要となります。 <verb> (standard-display-european 1) (load-library "iso-syntax") </verb> (訳注: mule も同様です。ただし対応するフォントが必要になります) <!-- If you are using Emacs on a terminal which has no 8-bit support, you can use the <tt>iso-ascii</tt> library (<tt>(load-library "iso-ascii")</tt>), which tells Emacs to display such characters to its best approximation. --> Emacs を使用しているターミナルが 8-bit をサポートしていない場合、 <tt>iso-ascii</tt> ライブラリーを使用することができます。これは Emacs に 8-bit 文字を表示させる為の最も近い指定です。 iso-ascii ライブラリーを使う場合、 <verb> (load-library "iso-ascii") </verb> <sect2> 8-bit 文字の入力 <!-- The typing of 8-bit characters --> <p> <!-- If your keyboard allows you to enter accented characters, no problem. If not here are some remedies: --> 使っているキーボードでアクセント付き記号の入力が入力できる場合、 何の問題もありません。もしそうでない場合は以下が助けになるでしょう。 <sect3> iso-acc ライブラリー <!-- The <tt>iso-acc</tt> library --> <p> <!-- The Emacs <tt>iso-acc</tt> library will let you type 8-bit characters from a 7-bit keyboard. --> Emacs の <tt>iso-acc</tt> ライブラリーは、7-bit キーボードから 8-bit 文字を入力 できるようにします。 <p> <!-- To use it, insert the following in your <tt>.emacs</tt> file: --> 使用するには、次の行を <tt>.emacs</tt> ファイルに入れてください。 <verb> (load-library "iso-acc") </verb> <p> <!-- Then, upon running Emacs and opening the file you need to edit, type <tt>Meta-x iso-accents-mode</tt>. --> それからエディットしたいファイルを実行中の Emacs 上でオープンし、 <tt>Meta-x iso-accents-mode</tt> を入力してください。 <p> <!-- You can then enter the <bf>é</bf> of the French word <em>café</em> typing <bf>'</bf> then <tt>e</tt>. More generally, you will type an accented character typing the accent first, then the letter to accent (upper or lower case). The following are the accents you may use: --> そうすれば、例えばフランス語の単語である <em>café</em> の <bf>é</bf> を、<bf>'</bf> に続けて <tt>e</tt> をタイプすることにより、 入力することができます。 一般的にはアクセント付き文字は、はじめにアクセント記号(')を、 次にアクセントの付けられる文字(大文字、小文字)を入力することに よって行えます。以下にアクセントの例を挙げます。 <!-- <list> <item><tt>'</tt>~: Acute <item><tt>`</tt>~: Grave <item><tt>^</tt>~: Circumflex <item><tt>"</tt>~: Dieresis <item><tt>˜</tt>~: Tilde, cedilla, and other particular cases (cf iso-acc.el). <item><tt>/</tt>~: To bar a letter, etc. </list> --> <!-- cz (? 1) Acute の読み方はアキュート? --> <list> <item><tt>'</tt>~: Acute <item><tt>`</tt>~: Grave グラーブ <item><tt>^</tt>~: Circumflex シルコンフレックス <item><tt>"</tt>~: Dieresis ディエレーズ <item><tt>˜</tt>~: Tilde ティルデ, cedilla セディーユ, およびその他の特定の記号 (iso-acc.el を参照) <item><tt>/</tt>~: 文字に斜線を引く、など。 </list> <!-- If you need one of these characters and not an accented letter, type a space next to it. For instance, to type <it>l'éléphant</it>, type <tt>l ' <cparam/spc/ ' e l ' e ...</tt> --> アクセント付き記号ではなく、上記の記号自体を入力したい場合、 記号の次にスペースを押してください。例えば、<it>l'éléphant</it> は <tt>l ' <cparam/spc/ ' e l ' e ...</tt> と入力します。 <p> <!-- You will find all the possible combinations in the <tt>iso-acc.el</tt> file. --> 全ての使用可能なコンビネーションは <tt>iso-acc.el</tt> ファイルの 中で見つける事ができます。 <sect3> メタキー <!-- The <cparam/Meta/ key --> <p> <!-- Some terminals will let you type 8-bit characters with the <cparam/Meta/ (or <cparam/Alt/) key. For example, pressing <bf><cparam/Meta/-i</bf> will get you the <bf>é</bf> character. --> いくつかのターミナルでは、<cparam/Meta/ (もしくは <cparam/Alt/)キーで 8-bit 文字を 入力できます。例えば、<bf><cparam/Meta/-i</bf> で <bf>é</bf> 文字を 入力できます。 <p> <!-- But Emacs reserved the <cparam/Meta/ key for other uses, and I know of no library which lets you use it for accented characters. --> しかし Emacs では <cparam/Meta/ キーは他の機能で使われています。また、アクセント 付き記号の入力を<Meta>キーで行うライブラリーを私は知りません。 <p> <!-- This is a solution: --> このような解決方法があります。 <verb> (global-set-key "\ei" '(lambda () (interactive) (insert ?\351))) _ ___ </verb> (訳注:上記の意味は、次のようになります。 <itemize> <item>global-set-key : 全てのモードで共通のキーバインドを定義 <item><bf>\e</bf> は ESC キーを表わしますので、 <bf>\ei</bf> は <bf><cparam/ESC/+i</bf> の事です。 <item>lambda : リストはラムダ式です。ラムダ式のリストはコマンドとして扱われます。 <item>リスト : ()で囲まれた中身と()自身の事をリストと呼びます。 <item>(interactive) : コマンドであり、対話的に(キー入力から)関数を 実行するという事を表します。 <item>(insert ?\351) : 文字コード \351 を(キー)入力したのと 同じ事になります) </itemize> <!-- Such a line, if inserted in your <tt>.emacs</tt> file, will let you type <bf>é</bf> using the <bf><cparam/Meta/-i</bf> keystroke. You can redefine in such a way the combinations you need if you replace <bf>i</bf> with the right key and <bf>351</bf> with the right code (the code being taken from the ISO-8859-1 character set). --> このような行を <tt>.emacs</tt> ファイルに入れると、<bf>é</bf> を <bf><cparam/Meta/-i</bf> で入力できるようになります。同じようにして必要な キーコンビネーションを、<bf>i</bf> や <bf>351</bf> を変更することによって 再定義することができます。(コードは ISO-8859-1 キャラクターセットのものです) <p> <!-- <bf>Warning!</bf> Some local modes may redefine such key combinations. --> <bf>注意!</bf> いくつかのローカルモードでキーコンビネーションを 再定義しているかもしれません。 <sect2> 8-bit SGML 文字の表示 <!-- The displaying of 8-bit SGML characters --> <p> <!-- Under SGML, you can type accented characters with macros. For example, the <bf/é/ key is <bf/&eacute;/. Generally, the applications that need to read SGML can read 8-bit characters and there is no need to use these macros. But some may not be able to do so. Given that there is a way to solve this problem, it would be a waste to let these crash. --> SGML では、アクセント付き記号をマクロで入力できます。例えば、<bf/é/ は <bf/&eacute;/ です。− 一般的には、SGML を読む必要のあるアプリケーションは 8-bit 文字を読む事ができますので、このようなマクロを使用する必要はありませんが、 読むことのできないものもあるかもしれません。その場合はマクロを使うことによって、 この問題を解決することができます。 <p> <!-- The <tt>iso-sgml</tt> library will let you type accented characters under Emacs, like always, but upon saving your file to the disk, it will turn these 8-bit characters into their SGML equivalent. --> <tt>iso-sgml</tt> ライブラリーもおなじように Emacs 上でアクセント付き記号の入力を 可能にしますが、これはファイルをディスクにセーブするときに、これらの 8-bit 文字を SGML の相当するものに変換します。 <p> <!-- It is therefore easy, thanks to this library, to type and reread your document under Emacs, and you can be sure a non 8-bit clean application will accept you document. --> このライブラリーのおかげでEmacs 上でのドキュメントの入力や編集作業は 簡単です、また 8-bit 対応ではないアプリケーションでもあなたのドキュメントを 扱う事ができるようになります。 <p> <!-- To use this library, you just need to add the following lines to your <tt>.emacs</tt> file: --> このライブラリーを使う為には、次の行を <tt>.emacs</tt> に追加するだけです。 <verb> (setq sgml-mode-hook '(lambda () "Defaults for SGML mode." (load-library "iso-sgml"))) </verb> (訳注: hook については、<htmlurl url="#hook_desc" name="auto-fill modeの訳注"> でメジャー/マイナーモードと共に説明しています) <sect1> SGML モード <!-- SGML mode --> <p> <!-- Upon loading a file with the <bf>.sgml</bf> extension, Emacs enters the <bf>sgml mode</bf> automatically. If it doesn't, you can tell it to do so manually by typing <tt>Meta-x sgml-mode</tt>, or automatically by adding the following lines to your <tt>.emacs</tt> file: --> <bf>.sgml</bf> という拡張子を持ったファイルをロードすると、Emacs は自動的に <bf>sgml モード</bf>になります。もし自動でならなかった場合、 <tt>Meta-x sgml-mode</tt> として手動で行えます。その場合、次の行を <tt>.emacs</tt> ファイルに追加することによって、自動的にモードが 切り変わるようにできます。 <verb> (setq auto-mode-alist (append '(("\.sgml$" . sgml-mode)) auto-mode-alist)) </verb> (訳注:<bf>autoc-mode-alist</bf> 変数には、読みこんだ拡張子によって自動的に変更 するモードがリスト形式で入っています。上記の例では <bf>.sgml</bf> という 拡張子のファイルを読みこんだ場合、<bf>sgml-mode</bf> というモードに自動的に 変わるように設定しています。同様にして他の拡張子の他のモードも追加できます) <!-- This mode will let you choose how to insert 8-bit characters for example. With <tt>Meta-x sgml-name-8bit-mode</tt> (or the menu item <it>SGML/Toggle 8-bit insertion</it>), you can choose to type 8-bit characters as is, or in SGML form, i.e. in the form <bf>&...;</bf>. --> このモードは、例えばどのように 8-bit 文字を入力するかを選択できるように します。<tt>Meta-x sgml-name-8bit-mode</tt> (またはメニューの <it>SGML/Toggle 8-bit insertion</it>)で、8-bit 文字をいつものように入力するか、 または SGML フォームで、\マクロ を記述します。 <!-- It will as well let you hide or show SGML tags, with <tt>Meta-x sgml-tags-invisible</tt> (or the menu item <it>SGML/Toggle Tag Visibility</it>). --> このモードでは、<tt>sgml-tags-invisible</tt>(またはメニューから <tt>SGML/Toggle Tag Visibility</tt>)で SGML タグの表示/非表示を行えます。 <sect1> PSGML モード <!-- PSGML mode --> <p> <!-- PSGML mode helps a lot to edit SGML documents with Emacs. --> PSGML モードは、Emacs 上での SGML ドキュメントの編集を楽にしてくれます。 <p> <!-- The <htmlurl name="psgml-linuxdoc" url="http://www.linux-france.com/article/psgml-linuxdoc"> documentation explains how to install this mode and use it with <it>LinuxDoc</it>. --> <htmlurl name="psgml-linuxdoc" url="http://www.linux-france.com/article/psgml-linuxdoc"> ドキュメントに、このモードのインストール方法と <it>LinuxDoc</it> での使い方についてが説明されています。 <sect1> その他 <!-- Miscellaneous --> <p> <sect2> auto-fill モード <!-- auto-fill mode --> <p> <!-- In the normal mode, when you type a paragraph and get to the end of the line, you must use the <cparam/Return/ key yourself to get to the next line, or else your line goes on through the whole paragraph. When you use <cparam/Return/ to get to the next line, you get a paragraph with ragged right margins. --> 通常のモードでは、パラグラフの入力時には行の最後で <cparam/Return/ キーを 押して改行する必要があります。改行をしなかった場合、パラグラフの全体が一つ に(一行)になってしまいます。改行するために <cparam/Return/ を使用した場合、 右マージンがでこぼこなパラグラフになってしまうでしょう。 <p> <!-- If you let some lines go beyond a reasonable width, you won't be able to see them with some editors. --> 適切な長さ以上の行は、エディターによっては見えなくなってしまうかも しれません。 <p> <!-- The <bf>auto-fill</bf> mode automates this boring task: when you go further than a certain column (the 70th by default), you are automatically taken to the next line. --> <bf>auto-fill</bf> モードは、このような面倒な作業を自動化してくれます。 指定のカラム(デフォルトでは 70)を越えた場合、自動的に改行されます。 <p> <!-- This is how to use this mode, and set the width of your lines to 80: --> このモードを使用するには、このように行います。例ではカラムを80に設定しています。 <!-- <verb> (setq sgml-mode-hook '(lambda () "Defaults for SGML mode." (auto-fill-mode) (setq fill-column 80))) </verb> --> <verb> (setq sgml-mode-hook '(lambda () "SGML モードのデフォルト" (auto-fill-mode) (setq fill-column 80))) </verb> <label id="hook_desc"> (訳注:<bf>Emacs/Mule</bf> には、メジャーモードとマイナーモードの2つがあり、 <bf>sgml-mode</bf> はメジャーモード、<bf>auto-fill-mode</bf> はマイナーモードです。 マイナーモードはどのメジャーモードとも同時に設定できます(できるはずです)。 ですから、上記の例だと <bf>sgml-mode</bf> になった時に同時に <bf>auto-fill-mode</bf> マイナーモードにもなるように指定していますが、他のモード (例えば <bf>text-mode</bf> など)で <bf>auto-fill-mode</bf> を指定することも 可能です。<bf>hook</bf> は、(通常)そのモードになる直前に実行されるルーチンの 事です。上記では <bf>sgml-mode-hook</bf> で記述してる為、<bf>sgml-mode</bf> に なった時のみ80カラムの <bf>auto-fill-mode</bf> になるようになっていますが、 コマンドとして実行したり <bf>.emacs</bf> などに記述する事によって 全モード共通/標準の設定を行う事も可能です) <sect>Ispell <p> <!-- If you want to spell-check your document from within Emacs, you may use the <bf>Ispell</bf> package and its Emacs mode. --> Emacs上でドキュメントのスペルチェックを行いたい場合、 <bf>Ispell</bf> パッケージ自身とそれの Emacs モードを使用する事ができます。 <sect1> デフォルト辞書の選択 <!-- Choosing your default dictionaries --> <p> <!-- You can set up Emacs so that upon loading a file, it chooses automatically which dictionaries to use (you can use several). The first one, certainly the most important, is the main dictionary, distributed with Ispell. You can choose among several languages. The second one is your personal dictionary, where Ispell will insert words it couldn't find in the main dictionary but you told it to remember. --> ファイルの読み込み時に、辞書を自動的に選択するように(複数の辞書も可能) Emacs をセットアップすることができます。まず一番目の、最も重要なものは Ispell と同時に配布されているメイン辞書です。複数の言語(の辞書)を選択 することもできます。二番目はあなた個人用の辞書で、メイン辞書になく、 あなたが登録した単語の格納先です。 <!-- If you wish to use as a default dictionary the French dictionary that comes with Ispell, and if you wish to use the file <tt>.ispell-dico-perso</tt> in your home directory as a personal dictionary, insert the following lines in your <tt>.emacs</tt> file: --> Ispell と同時に配布されているフランス語の辞書をデフォルト辞書、 ホームディレクトリの <tt>.ispell-dico-perso</tt> ファイルを個人用辞書として 使用したい場合、<tt>.emacs</tt> ファイルに以下の行を追加してください。 (訳注:この文書のオリジナルはフランス語で書かれています。<bf>dico</bf> は <bf>dictionnaire</bf>(辞書)、<bf>perso</bf> は <bf>personnel</bf>(個人)の 略です。ですから、<bf>dico-perso</bf> は、個人用辞書という意味になります) <!-- <verb> (setq sgml-mode-hook '(lambda () "Defauts for SGML mode." '(lambda () "SGML モードのデフォルト" (setq ispell-personal-dictionary "~/.ispell-dico-perso") (ispell-change-dictionary "francais") )) </verb> --> <verb> (setq sgml-mode-hook '(lambda () "SGML モードのデフォルト" (setq ispell-personal-dictionary "~/.ispell-dico-perso") (ispell-change-dictionary "francais") )) </verb> <sect1> ファイルの言語に対応した辞書の選択 <!-- Selecting special dictionaries for certain files --> <p> <!-- You may have a little problem if you do not spell-check documents in the same language at all times. If you translate documents, it is very likely that you swap languages (and dictionaries) very often. --> 複数の言語でのスペルチェックを行う場合、多少の問題があるかもしれません。 例えばドキュメントの翻訳など、言語(及び辞書)を頻繁に切り替える時などです。 <p> <!-- I don't know of any Lisp way of selecting, either automatically, or with a single mouse click, the main and personal dictionaries associated to the language currently being used. (If you do, please tell me!) --> 私には Lisp で自動的に、もしくはマウスクリック一回で、使用中の言語の メイン辞書・個人辞書を切り替える方法はわかりません(もし御存じでしたら ぜひ教えて下さい!) <p> <!-- However, it is possible to indicate, at the end of the file, which dictionaries you want to use for the current file (and only this one). It suffices to add them as commentaries, so that Ispell can read them upon launching a spell-check: --> けれども、現在のファイルでどの辞書を使用するか(またその辞書のみ使用す ること)をファイルの末尾で指示する事が可能です。コメントとして指定を 追加する事によって、spell-check の起動時に Ispell はそれを読みこむ事が できます。 <verb> <!-- Local IspellDict: english --> <!-- Local IspellPersDict: ~/emacs/.ispell-english --> </verb> <!-- If you have previously defined, in your <tt/.emacs/ file, that your default dictionaries are the French dictionaries, then you can add these lines in the end of any file written in English. --> 例えば <tt>.emacs</tt> ファイルにデフォルトの辞書としてフランス語の辞書を 指定している場合に、英語で書かれたファイルの末尾にこの行を追加する事が できます。(追加することによって、英語の辞書を使用することができます) <sect1> 文書のスペルチェック <!-- Spell-checking your document --> <p> <!-- To spell-check the whole of your document, use, from anywhere in the document the <tt>Meta-x ispell-buffer</tt> command. You may as well only run the checking on a region in your document: --> 文書全体をスペルチェックする場合、文書のどこからでも <tt>Meta-x ispell-buffer</tt> コマンドを使用できます。また次のようにして、文書のリージョンのみを チェックすることも可能です。 (訳注:リージョンとは、指定された範囲全体のことです) <!-- <itemize> <item> Mark the beginning of the region with <tt>Ctrl-Spc</tt> (mark-set-command), <item> Go to the end of the region to check, <item> type <tt>Meta-x ispell-region</tt>. </itemize> --> <itemize> <item>リージョンの先頭を <tt>Ctrl-Spc</tt>(mark-set-command)で指定 <item>スペルチェックする範囲の最後へカーソルを移動 <item><tt>Meta-x ispell-region</tt> コマンドを実行 </itemize> <!-- Emacs then runs Ispell. Upon meeting an unknown word, this one shows you said word (usually highlighted) and prompts you for a key: --> そうすると Emacs は Ispell を起動します。未知の単語を見つけた時、 (通常ハイライト表示で)その単語を表示し、以下のようなキー入力を待ちます。 <!-- <itemize> <item><bf>spc </bf>accepts the word, this time only, <item><bf>i </bf>accepts the word and inserts it in your personal dictionary, <item><bf>a </bf>accepts the word for this session, <item><bf>A </bf>accepts the word for this file, and inserts it in the local file dictionary <item><bf>r </bf>allows you to correct the word by hand <item><bf>R </bf>allows you to correct all the occurrences of the misspelled word, <item><bf>x </bf>stops the checking, and puts the cursor back in place, <item><bf>X </bf>stops the checking and leaves the cursor where it is, letting you correct your file; you will be able to continue the spell-checking later if you type <tt>Meta-x ispell-continue</tt>, <item><bf>? </bf>gives you online help. </itemize> --> <itemize> <item><bf>spc</bf> は今回のみ単語を正しいものとします <item><bf>i</bf> は単語を正しいものとし、個人用辞書に単語登録をします <item><bf>a</bf> は単語を今回のセッションの間、正しいものとします <item><bf>A</bf> は単語を正しいものとし、ローカルファイル辞書に登録します <item><bf>r</bf> は手動で、正しい単語の入力を行います <item><bf>R</bf> は以後のミススペルの単語すべてを、 手動で入力した正しい単語で置換します <item><bf>x</bf> はスペルチェックを終了し、 カーソルをチェックを開始した位置に戻します。 <item><bf>X</bf> はスペルチェックを終了しますが、カーソル は現在の位置のままです。これによりその場からファイルの修正を行うことができます。 <tt>Meta-x ispell-continue</tt> コマンドを実行することによって、スペルチェックを 続行することもできます。 <item><bf>?</bf> はオンラインヘルプの表示を行います </itemize> <!-- If ispell finds one or several words close to the unknown one, it will show them in a little window, each one of them preceded by a digit. Just type this digit to replace the misspelled word with the corresponding word. --> ispell が未知の単語に近い単語を見つけた場合、小さなウィンドウを開いて そこに通番を付けて表示します。ミススペルした単語を置き換えるには その番号を単に押すだけでできます。 <sect1> 個人用辞書 vs ローカルファイル辞書 <!-- Personal dictionary versus local file dictionary --> <p> <!-- The <bf>i</bf> key will let you insert a word in your personal dictionary, whereas <bf>A</bf> will let you insert a word in the local file dictionary. --> <bf>i</bf> キーは単語を個人用辞書に、対して <bf>A</bf> は単語を ローカルファイル辞書に登録します。 <p> <!-- The local file dictionary is a sequence of words inserted at the end of the file, as comments, reread by Ispell each time it is run on the file. This way, you can accept some words, acceptable in this file, but not necessarily acceptable in other files. --> ローカルファイル辞書は、ファイルの末尾にコメントとして挿入された単語の 集まりで、そのファイルを扱う時に Ispell により再度読みこまれます。 これにより、このファイルでのみその単語を既知とする事ができます。 <p> <!-- As far as I am concerned, I think it is better that the personal dictionary be reserved for words the main dictionary doesn't know but which belong to the language (like hyphenated words), plus some common words like proper nouns or others (like <it>Linux</it>), if they don't look too much like a real word of the main dictionary; adding too many words in the personal dictionary, such as first names, may be dangerous, because they may look like a word of the language (one can imagine Ispell being mystified on the following: `<it>When the going gets tof, the tof get going</it><footnote> <em>Tof</em> is a French abbreviation for the first name <em>Christophe</em>.</footnote>'!). --> 私自身の考えでは個人用辞書には、使用している言語のメイン辞書に無く(例 えばハイフンのついた単語など)、<it>Linux</it> のような固有名詞や造語のような 単語を登録すべきだと思います。ミススペルした単語を既知の単語として扱って しまうかもしれないので、名前などを個人用辞書に大量に登録することは危険 かもしれません。例えば、次のような場合、Ispell は惑わされてしまいます (訳注:未知の単語を既知と扱ってしまいます)。 <it>`When the going gets tof, the tof get going'</it> <footnote>(<em>Tof</em> は、名字(フランス語)を略したものです)</footnote> <sect1>スペルチェック入力 <!-- Typing spell-checking --> <p> <!-- Ispell can spell-check your file while you're typing. You need to use <bf>ispell-minor-mode</bf> for this. To start it or stop it, type <tt>Meta-x ispell-minor-mode</tt>. Ispell will <em>beep</em> you each time you type a word it doesn't know. --> Ispell は入力と同時にスペルチェックすることができます。そのためには、 <bf>ispell-minor-mode</bf> を使用します。モードの開始終了は、 <tt>Meta-x ispell-minor-mode</tt> コマンドを実行します。Ispell は未知の単語が 入力されると<em>ビープ音</em>を鳴らします。 <p> <!-- If those <em>beeps</em> hassle you (or your roommate is taking a nap), you can replace those annoying <em>beeps</em> with a flash on the screen, with the command <tt>Meta-x set-variable RET visible-bell RET t RET</tt>. You can add the following line in your <tt>.emacs</tt> and silence Emacs forever: --> もし<em>ビープ音</em>がわずらわしい(うたた寝しているルームメイトがいる時とか) 場合、<tt>Meta-x set-variable リターン visible-bell リターン t リターン</tt> を 入力して、<em>ビープ</em>を鳴らす代わりに画面をフラッシュさせることができます。 次の行を <tt>.emacs</tt> に記述する事によって、常にビープ音を鳴らさないように することもできます。 <verb> (setq visible-bell t) </verb> <sect>力技 <!-- Dirty Tricks --> <sect1>ヘッダーの自動挿入 <!-- Inserting a header automatically --> <p> <!-- Emacs allows you to <em>hook</em> some actions to any event (opening of a file, saving, running a new mode, etc). --> Emacs ではファイルのオープン、セーブ、新しいモードの起動など、 イベントに対するアクションを<em>フック</em>することができます。 <p> <!-- The <bf>autoinsert</bf> library uses this feature: when you open a new file under Emacs, this library inserts, according to the type of the file, a <em>standard</em> header. --> <bf>autoinsert</bf> ライブラリーはこの機能を使用します。たとえば Emacs 上で ファイルを起動した場合、ファイルのタイプによりこのライブラリーは <em>標準の</em>ヘッダーを挿入します。 <p> <!-- In our case, this <em>standard</em> header could well be the part declaring the document type (LinuxDoc), the title, the author, and the date. --> 私たちのケースの場合、この<em>標準の</em>ヘッダーとは LinuxDoc 型のタイトル、 著者、日付のことです。 <p> <!-- I will describe here two ways to insert such a header. You could insert a template file containing the information to insert, or you could run an <bf>elisp</bf> routine. --> ここではヘッダーを挿入する方法を、2つ解説します。挿入する情報を含んだ テンプレートファイルを追加する方法と、<bf>elisp</bf> のルーチンを 実行する方法の2つです。 <sect2> ファイルを挿入する場合 <!-- by inserting a file --> <p> <!-- You must first tell Emacs to run the <tt>auto-insert</tt> when opening a file, then to read the <bf>autoinsert</bf> library which declares the <tt>auto-insert-alist</tt> list which we need to change. This list defines the header to insert for each file type. By default, the file to insert must be in the <tt>~/insert/</tt> directory, but it is possible to redefine the <tt>auto-insert-directory</tt> variable if you want to put it somewhere else. --> ファイルをオープンしてまず始めに、Emacs 上で <tt>auto-insert</tt> を実行する 必要があります。それから、<tt>auto-insert-alist</tt> リストを持っている <bf>autoinsert</bf> ライブラリを読みこみます。このリストはファイルの種類別の ヘッダーを定義していますので、これを修正する必要があります。 デフォルトでは <tt>~/insert/</tt> ディレクトリに、挿入するヘッダーの含まれた ファイルがありますが、<tt>auto-insert-directory</tt> 変数を変更することによって ファイルの場所を再定義することができます。 <p> <!-- Add the following lines to your <tt>.emacs</tt> file to insert the <tt>~/emacs/sgml-insert.sgml</tt> file each time you open a new SGML file: --> SGML ファイルをオープンする度に <tt>~/emacs/sgml-insert.sgml</tt> ファイルを 挿入するには、次の行を <tt>.emacs</tt> ファイルに追加してください。 <verb> (add-hook 'find-file-hooks 'auto-insert) (load-library "autoinsert") (setq auto-insert-directory "~/emacs/") (setq auto-insert-alist (append '((sgml-mode . "sgml-insert.sgml")) auto-insert-alist)) </verb> (訳注: <bf>alist</bf> は連想リストの事です。例えば、 <tt>'(pine . cones)</tt> の場合、<bf>pine</bf> というキーは <bf>cones</bf> と いう値に関連づけられます(真ん中の <bf>.</bf> を忘れずに!)。 またリストの先頭に <bf>'</bf> が付いてない場合、リストの初めの 要素は関数名を表します。<tt>(foo bar)</tt> は <bf>foo</bf> 関数に <bf>bar</bf> という引数を渡しています。<tt>'(foo bar)</tt> は単に <bf>foo</bf> と <bf>bar</bf> という要素の入ったリストです) <!-- You can then write in the <tt>~/emacs/sgml-insert.sgml</tt> file your customised header, then re-run Emacs and open some <tt>foobar.sgml</tt> file. Emacs should ask you to confirm the automatic insertion, and if you answer yes, insert your header. --> これで <tt>~/emacs/sgml-insert.sgml</tt> に好きなヘッダーを記述できます。 Emacs を再起動して(訳注:<tt>.emacs</tt> を開いて <tt>Meta-x eval-current-buffer</tt> でもよい)適当な <tt>.sgml</tt> ファイルを 起動してみてください。すると Emacs は自動挿入の確認を表示します。 yes と答えるとあなたの作成したヘッダーが挿入されます。 <sect2> ルーチンを実行する場合 <!-- by running a routine --> <p> <!-- This works like before, but instead of setting the <tt>auto-insert-alist</tt> to a file to insert, you need to set it to a function to execute. This is how to proceed, taking for granted you want to write this function in a file named <tt>~/emacs/sgml-header.el</tt>. (there's no need to burden your <tt>.emacs</tt> file with such a function, as it may turn out to be quite long): --> これはファイルを挿入する場合と同じように動作しますが、 <tt>auto-insert-alist</tt> に挿入するヘッダーのファイルを追加する代りに、 実行する関数を追加します。 ここではどのように準備するかという事のみを扱います。当然この関数の名前は <tt>~/emacs/sgml-header.el</tt> にしたい事でしょう。(非常に 長くなってしまうと思われる、関数の定義は <tt>.emacs</tt> ファイルの中に 記述する必要はありません) <verb> (add-hook 'find-file-hooks 'auto-insert) (load-library "autoinsert") (add-to-list 'load-path "~/emacs") (load-library "sgml-header") (setq auto-insert-alist (append '(((sgml-mode . "SGML Mode") . insert-sgml-header)) auto-insert-alist)) </verb> <!-- You will find in <ref id="insert-sgml-header" name="appendix"> an example of <tt>insert-sgml-header</tt> function. --> <tt>insert-sgml-header</tt> 関数の例は、 <ref id="insert-sgml-header" name="appendix"> にあります。 <appendix> <sect> insert-sgml-header 関数 <label id="insert-sgml-header"> <!-- An <tt>insert-sgml-header</tt> function <label id="insert-sgml-header"> --> <p> <!-- This function will let the user insert a customised header for a Linux Documentation Project document in a file. It can be called automatically when one opens a new file, or explicitly, by the user. --> この関数は、ユーザーの利便の為に Linux Documentation Projetct ドキュメ ントをファイルに挿入します。この関数はファイルをオープンした時に自動的、 もしくはユーザーが明示的に指定する事によって呼び出されます。 <p> <!-- This function prompts the user, through the <em>mini-buffer</em>, for some pieces of information, some of which are necessary, some of which are not. --> この関数は <em>mini-buffer</em> からユーザーにいくつかの情報の入力を促しますが、 入力必須の物と、そうでないものがあります。 <!-- First comes the title. If none is given, the function returns immediately, and inserts nothing. Then comes the date, the author, his e-mail and home page (these last two are optional). --> 始めにタイトルの入力を促します。何も入力されなかった場合、何も挿入せずに 関数の実行を終了します。次に日付、著者、著者の e-mail、そして ホームページです(e-mail と home page の入力はオプションです)。 <!-- Then comes a request for the name of the translator. If there is none, just type <em>Return</em>, and no further prompting about a hypothetical translator will be done. If there is one, you are asked for his e-mail and home page (optional as well). --> その次は翻訳者の名前の入力ですが、関係が無い場合は単に <em>Return</em> を押せば、翻訳者に関係する情報の入力はこれ以上促されません。 名前を入力した場合、e-mail と home page の入力をするように表示されます (同様にこの2つはオプションです)。 <!-- This function then prints your request to the current buffer, including of course all the information you typed in a set up form, and including as well the tags which will serve for the abstract and the first chapter. It finally puts the cursor in the place where the abstract needs to be typed. --> 入力が終わるとカレントのバッファに、入力した情報と abstract, toc, sect タグが挿入されます。最後にカーソルを、概要を入力する場所(訳注:つまり <bf><abstract></bf> と <bf>&etago;abstract></bf> の間)に 移動して実行を終了します。 <verb> (defun insert-sgml-header () "Inserts the header for a LinuxDoc document" (interactive) (let (title author email home translator email-translator home-translator date starting-point) (setq title (read-from-minibuffer "Title: ")) (if (> (length title) 0) (progn (setq date (read-from-minibuffer "Date: ") author (read-from-minibuffer "Author: ") email (read-from-minibuffer "Author e-mail: ") home (read-from-minibuffer "Author home page: http://") translator (read-from-minibuffer "Translator: ")) (insert "<!doctype linuxdoc system>\n<article>\n<title>") (insert title) (insert "&etago;title>\n<author>\nAuthor: ") (insert author) (insert "&nl;\n") (if (> (length email) 0) (progn (insert "<htmlurl url=\"mailto:") (insert email) (insert "\" name=\"") (insert email) (insert "\">&nl;\n"))) (if (> (length home) 0) (progn (insert "<htmlurl url=\"http://") (insert home) (insert "\" name=\"") (insert home) (insert "\">\n&nl;"))) (if (> (length translator) 0) (progn (setq email-translator (read-from-minibuffer "Translator e-mail: ") home-translator (read-from-minibuffer "Translator home page: http://")) (insert "Translator : ") (insert translator) (insert "&nl;\n") (if (> (length email-translator) 0) (progn (insert "<htmlurl url=\"mailto:") (insert email-translator) (insert "\" name=\"") (insert email-translator) (insert "\">&nl;\n"))) (if (> (length home-translator) 0) (progn (insert "<htmlurl url=\"http://") (insert home-translator) (insert "\" name=\"") (insert home-translator) (insert "\">&nl;\n"))))) (insert "&etago;author>\n<date>\n") (insert date) (insert "\n&etago;date>\n\n<abstract>\n") (setq point-beginning (point)) (insert "\n&etago;abstract>\n<toc>\n\n<sect>\n<p>\n\n\n&etago;sect>\n\n&etago;article>\n") (goto-char point-beginning) )))) </verb> <sect>訳者あとがき <p> 日本語訳は Linux-JF プロジェクトの方々から多くのご助言を頂きました。 ありがとうございます。 日本語訳:早川 仁<newline> 1999年 2月27日 </article> <!-- Local IspellDict: english --> <!-- Local IspellPersDict: ~/emacs/.ispell-english --> <!-- Local IspellDict: english --> <!-- Local IspellPersDict: ~/emacs/.ispell-english --> <!-- LocalWords: bastien HOWTOs rushy HTML Dieresis phant eacute sgml caf --> <!-- LocalWords: tof Christophe autoinsert elisp Blondeel spc XEmacs -->