文字プロパティ(character propertyとは、その文字の振る舞いとテキストが処理や表示される間にどのように処理されるべきかを指定する名前つきの文字属性です。したがって文字プロパティはその文字の意味を指定するための重要な一部です。
全体としてEmacsは自身の文字プロパティ実装においてUnicode標準にしたがいます。特にEmacsはUnicode Character Property Modelをサポートしており、Emacs文字プロパティデータベースはUnicode文字データベース(UCD: Unicode Character Database)から派生したものです。Unicode文字プロパティとその意味についての詳細な説明はCharacter Properties chapter of the Unicode Standardを参照してください。このセクションではあなたがすでにUnicode標準の該当する章に親しんでいて、その知識をEmacs Lispプログラムに適用したいものと仮定します。
Emacsでは各プロパティは名前をもつシンボルであり、そのシンボルは利用可能な値セットをもち、値の型はプロパティに依存します。ある文字が特定のプロパティをもたなければ、その値はnilになります。一般的なルールとしてEmacsでの文字プロパティ名は対応するUnicodeプロパティ名を小文字にして、文字‘_’をダッシュ文字‘-’で置き換えることにより生成されます。たとえばCanonical_Combining_Classはcanonical-combining-classとなります。しかし簡単に使用できるように名前を短くすることもあります。
UCDによりいくつかのコードポイントは未割り当て(unassigned)のまま残されており、それらに対応する文字はありません。Unicode標準は、そのようなコードポイントのプロパティにたいしてデフォルト値を定義しています。それらについては以下の各プロパティごとに注記することにします。
以下はEmacsが関知するすべての文字プロパティにたいする値タイプの完全なリストです:
nameUnicodeプロパティNameに対応する。値はラテン大文字のAからZ、数字、スペース、ハイフン‘-’の文字から構成される文字列。未割り当てのコードポイントにたいする値はnil。
general-category ¶UnicodeプロパティGeneral_Categoryに対応する。値はその文字の分類をアルファベット2文字に略したものを名前としてもつようなシンボル。未割り当てのコードポイントにたいする値はCn。
canonical-combining-classUnicodeプロパティCanonical_Combining_Classに対応する。値は整数。未割り当てのコードポイントにたいする値は0。
bidi-class ¶UnicodeプロパティBidi_Classに対応する。値はその文字のUnicode方向タイプ(directional
type)が名前であるようなシンボル。Emacsは表示のために双方向テキストを並び替える際にこのプロパティを使用する(双方向テキストの表示を参照)。未割り当てのコードポイントにたいする値はそのコードポイントが属するコードブロックに依存する。未割り当てのコードポイントのほとんどはL(強い左方向)だが、AL
( Arabic letter: アラビア文字)やR (強い右方向)を受け取るコースポイントもいくつかある。
decompositionUnicodeプロパティのDecomposition_TypeとDecomposition_Valueに対応する。値は最初の要素がsmallのような互換性のあるフォーマットタグ(compatibility
formatting
tag)であるかもしれないリスト26。分割シーケンス(compatibility
decomposition
sequence)をもたない文字、および未割り当てのコードポイントにたいする値はその文字自身が唯一のメンバーであるようなリスト。
decimal-digit-valueNumeric_Typeが‘Decimal’であるような文字UnicodeプロパティNumeric_Valueに対応する。値は整数、その文字が10進値をもたなければnil。未割り当てのコードポイントにたいする値は、NaNまたは“not
a number(数字ではない)”を意味するnil。
digit-valueNumeric_Typeが‘Digit’であるような文字のUnicodeプロパティNumeric_Valueに対応する。値は整数。このような文字には互換性のある添字や上付き数字が含まれ、値は対応する数字。何も数値をもたない文字および未割り当てのコードポイントにたいする値はNaNを意味するnil。
numeric-valueNumeric_Typeが‘Numeric’であるような文字のUnicodeプロパティNumeric_Valueに対応する。このプロパティの値は数字。このプロパティをもつ文字の例には分数、添字、上付き数字、ローマ数字、通貨分数(訳注:
原文は“currency numerators”でベンガル語の分数値用の歴史的な記号を指すと思われる)、丸数字が含まれる。たとえば文字U+2155
(VULGAR FRACTION ONE FIFTH:
(訳注)スラッシュで分子と分母を区切った表記による5分の1のこと)にたいするこのプロパティの値は0.2。数値をもたない文字と未割り当てのコードポイントにたいする値はNaNを意味するnil。
mirrored ¶UnicodeプロパティBidi_Mirroredに対応する。このプロパティの値はYかNいずれかのシンボル。未割り当てのコードポイントにたいする値はN。
mirroringUnicodeプロパティBidi_Mirroring_Glyphに対応する。このプロパティの値は、そのグリフ(glyph)がその文字のグリフの鏡像(mirror
image)を表すような文字、定義済みの鏡像グリフがなければnil。mirroredプロパティがNであるようなすべての文字のmirroringプロパティはnil。しかしmirroredプロパティがYの文字でも、鏡像をもつ適切な文字がないという理由によりmirroringがnilの文字もある。Emacsは適切な際は鏡像を表示するためにこのプロパティを使用する(双方向テキストの表示を参照)。未割り当てのコードポイントにたいする値はnil。
paired-bracketUnicodeプロパティBidi_Paired_Bracketに対応する。このプロパティの値は文字のpaired
bracket(カッコのペア)のコードポイント、その文字がbracket文字でなければnil。これはUnicode双方向アルゴリズム(Unicode
Bidirectional Algorithm)によりカッコのペアとして扱われる文字間のマッピングを確立する。
Emacsは丸カッコ(parentheses)や角カッコ(braces)、およびその類の文字を再配置する方法を決定する際にこのプロパティを使用する(双方向テキストの表示を参照)。
bracket-typeUnicodeのBidi_Paired_Bracket_Typeプロパティに対応する。paired-bracketプロパティが非nilの文字にたいするこのプロパティはo
(開カッコ文字)かc
(閉カッコ文字)を表すシンボルのいずれか。paired-bracketプロパティがnilの文字にたいする値はn
(None: なし)。paired-bracketと同じようにこのプロパティは双方向ディスプレイにより使用される。
old-nameUnicodeプロパティUnicode_1_Nameに対応する。値は文字列。未割り当てのコードポイント、およびこのプロパティにたいする値をもたない文字では値はnil。
iso-10646-commentUnicodeプロパティISO_Commentに対応する。値は文字列かnil。未割り当てのコードポイントにたいする値はnil。
uppercaseUnicodeプロパティSimple_Uppercase_Mappingに対応する。このプロパティの値は単一の文字。未割り当てのコードポイントの値はnilであり、これはその文字自身を意味する。
lowercaseUnicodeプロパティSimple_Lowercase_Mappingに対応する。このプロパティの値は単一の文字。未割り当てのコードポイントの値はnilであり、これはその文字自身を意味する。
titlecaseUnicodeプロパティSimple_Titlecase_Mappingに対応する。タイトルケース(title
case)とは単語の最初の文字を大文字にする必要がある際に使用される文字の特別な形式のこと。このプロパティの値は単一の文字。未割り当てのコードポイントにたいする値はnilであり、これはその文字自身を意味する。
special-uppercaseCorresponds to Unicode language- and context-independent special
upper-casing rules. The value of this property is a string (which may be
empty). For example for U+00DF LATIN SMALL LETTER SHARP S the value is
"SS". This mapping overrides the uppercase property, and thus
the current case table. For characters with no special mapping, the value
is nil, which means the uppercase property needs to be
consulted instead.
special-lowercaseCorresponds to Unicode language- and context-independent special
lower-casing rules. The value of this property is a string (which may be
empty). For example for U+0130 LATIN CAPITAL LETTER I WITH DOT ABOVE
the value is "i\u0307" (i.e., a 2-character string consisting of
LATIN SMALL LETTER I followed by U+0307 COMBINING DOT ABOVE).
This mapping overrides the lowercase property, and thus the current
case table. For characters with no special mapping, the value is
nil, which means the lowercase property needs to be consulted
instead.
special-titlecaseCorresponds to Unicode unconditional special title-casing rules. The value
of this property is a string (which may be empty). For example for U+FB01
LATIN SMALL LIGATURE FI the value is "Fi". This mapping
overrides the titlecase property, and thus the current case table.
For characters with no special mapping, the value is nil, which means
the titlecase property needs to be consulted instead.
この関数はcharのプロパティpropnameの値をリターンする。
(get-char-code-property ?\s 'general-category)
⇒ Zs
(get-char-code-property ?1 'general-category)
⇒ Nd
;; U+2084
(get-char-code-property ?\N{SUBSCRIPT FOUR}
'digit-value)
⇒ 4
;; U+2155
(get-char-code-property ?\N{VULGAR FRACTION ONE FIFTH}
'numeric-value)
⇒ 0.2
;; U+2163
(get-char-code-property ?\N{ROMAN NUMERAL FOUR}
'numeric-value)
⇒ 4
(get-char-code-property ?\( 'paired-bracket)
⇒ 41 ; closing parenthesis
(get-char-code-property ?\) 'bracket-type)
⇒ c
この関数はプロパティpropのvalueの説明文字列(description
string)、valueが説明をもたなければnilをリターンする。
(char-code-property-description 'general-category 'Zs)
⇒ "Separator, Space"
(char-code-property-description 'general-category 'Nd)
⇒ "Number, Decimal Digit"
(char-code-property-description 'numeric-value '1/5)
⇒ nil
この関数は文字charのプロパティpropnameの値としてvalueを格納する。
この変数の値は、それぞれの文字にたいしてそのUnicodeプロパティGeneral_Categoryをシンボルとして指定する文字テーブル(文字テーブルを参照)。
The value of this variable is a char-table that specifies, for each character, a symbol whose name is the script to which the character belongs, according to the Unicode Standard classification of the Unicode code space into script-specific blocks. This char-table has a single extra slot whose value is the list of all script symbols. Note that Emacs’s classification of characters into scripts is not a 1-for-1 reflection of the Unicode standard, for example there is no ‘symbol’ script in Unicode.
この変数の値は、それぞれの文字がスクリーン上で占めるであろう幅を列単位で指定する文字テーブル。
この変数の値は、それぞれの文字にたいしてそれがプリント可能かどうかを指定する文字テーブル。すなわち(aref printable-chars
char)を評価した結果がtならプリント可、nilなら不可。
Unicode仕様ではこれらのタグ名を‘<..>’カッコ内に記述しますがEmacsでのタグ名にはカッコは含まれません。Unicodeでの‘<small>’指定はEmacsでは‘small’となります。