-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtext.texi
5302 lines (4703 loc) · 268 KB
/
text.texi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
@c -*-texinfo-*-
@c This is part of the GNU Emacs Lisp Reference Manual.
@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998 Free Software Foundation, Inc.
@c See the file elisp.texi for copying conditions.
@setfilename ../info/text
@node Text, Non-ASCII Characters, Markers, Top
@c @chapter Text
@chapter テキスト
@c @cindex text
@cindex テキスト
@c This chapter describes the functions that deal with the text in a
@c buffer. Most examine, insert, or delete text in the current buffer,
@c often in the vicinity of point. Many are interactive. All the
@c functions that change the text provide for undoing the changes
@c (@pxref{Undo}).
本章では、バッファ内のテキストを扱う関数について述べます。
それらのほとんどは、カレントバッファ内のテキストを
調べたり挿入したり削除しますが、しばしばポイント付近で行います。
多くは対話的に使えます。
テキストを変更するすべての関数は、変更を取り消せます(@pxref{Undo})。
@c Many text-related functions operate on a region of text defined by two
@c buffer positions passed in arguments named @var{start} and @var{end}.
@c These arguments should be either markers (@pxref{Markers}) or numeric
@c character positions (@pxref{Positions}). The order of these arguments
@c does not matter; it is all right for @var{start} to be the end of the
@c region and @var{end} the beginning. For example, @code{(delete-region 1
@c 10)} and @code{(delete-region 10 1)} are equivalent. An
@c @code{args-out-of-range} error is signaled if either @var{start} or
@c @var{end} is outside the accessible portion of the buffer. In an
@c interactive call, point and the mark are used for these arguments.
テキスト関連の多くの関数は、@var{start}と@var{end}という名前の引数で渡された
2つのバッファ内位置で定義されるテキストの領域に作用します。
これらの引数は、マーカ(@pxref{Markers})であるか
文字の位置を表す数値(@pxref{Positions})である必要があります。
これらの引数の順番は関係なく、@var{start}が領域の終了位置で
@var{end}が開始位置であってもまったく問題ありません。
たとえば、@code{(delete-region 1 10)}と@code{(delete-region 10 1)}は同値です。
@var{start}や@var{end}がバッファの参照可能部分の外側にあると
エラー@code{args-out-of-range}を通知します。
対話的な呼び出しでは、ポイントとマークをこれらの引数として使います。
@c @cindex buffer contents
@cindex バッファの内容
@c Throughout this chapter, ``text'' refers to the characters in the
@c buffer, together with their properties (when relevant).
本章では、バッファ内の文字を(関係あるときには)
それらのテキスト属性を含めて『テキスト』と呼びます。
@menu
* Near Point:: Examining text in the vicinity of point.
* Buffer Contents:: Examining text in a general fashion.
* Comparing Text:: Comparing substrings of buffers.
* Insertion:: Adding new text to a buffer.
* Commands for Insertion:: User-level commands to insert text.
* Deletion:: Removing text from a buffer.
* User-Level Deletion:: User-level commands to delete text.
* The Kill Ring:: Where removed text sometimes is saved for later use.
* Undo:: Undoing changes to the text of a buffer.
* Maintaining Undo:: How to enable and disable undo information.
How to control how much information is kept.
* Filling:: Functions for explicit filling.
* Margins:: How to specify margins for filling commands.
* Adaptive Fill:: Adaptive Fill mode chooses a fill prefix from context.
* Auto Filling:: How auto-fill mode is implemented to break lines.
* Sorting:: Functions for sorting parts of the buffer.
* Columns:: Computing horizontal positions, and using them.
* Indentation:: Functions to insert or adjust indentation.
* Case Changes:: Case conversion of parts of the buffer.
* Text Properties:: Assigning Lisp property lists to text characters.
* Substitution:: Replacing a given character wherever it appears.
* Transposition:: Swapping two portions of a buffer.
* Registers:: How registers are implemented. Accessing the text or
position stored in a register.
* Change Hooks:: Supplying functions to be run when text is changed.
@end menu
@node Near Point
@c @section Examining Text Near Point
@section ポイント付近のテキストを調べる
@c Many functions are provided to look at the characters around point.
@c Several simple functions are described here. See also @code{looking-at}
@c in @ref{Regexp Search}.
多くの関数は、ポイント付近の文字を調べるためのものです。
ここでは、数個の単純な関数について述べます。
@ref{Regexp Search}の@code{looking-at}も参照してください。
@defun char-after &optional position
@c This function returns the character in the current buffer at (i.e.,
@c immediately after) position @var{position}. If @var{position} is out of
@c range for this purpose, either before the beginning of the buffer, or at
@c or beyond the end, then the value is @code{nil}. The default for
@c @var{position} is point.
この関数は、カレントバッファ内の位置@var{position}にある
(つまり直後の)文字を返す。
@var{position}がバッファの先頭のまえや末尾のうしろにあるなどして
この目的に適した範囲の外側にあると、値は@code{nil}である。
@var{position}のデフォルトはポイントである。
@c In the following example, assume that the first character in the
@c buffer is @samp{@@}:
つぎの例では、バッファの最初の文字は@samp{@@}であると仮定する。
@example
@group
(char-to-string (char-after 1))
@result{} "@@"
@end group
@end example
@end defun
@defun char-before &optional position
@c This function returns the character in the current buffer immediately
@c before position @var{position}. If @var{position} is out of range for
@c this purpose, either before the beginning of the buffer, or at or beyond
@c the end, then the value is @code{nil}. The default for
@c @var{position} is point.
この関数は、カレントバッファ内の位置@var{position}のまえにある文字を返す。
@var{position}がバッファの先頭のまえや末尾のうしろにあるなどして
この目的に適した範囲の外側にあると、値は@code{nil}である。
@var{position}のデフォルトはポイントである。
@end defun
@defun following-char
@c This function returns the character following point in the current
@c buffer. This is similar to @code{(char-after (point))}. However, if
@c point is at the end of the buffer, then @code{following-char} returns 0.
この関数は、カレントバッファのポイントのうしろにある文字を返す。
これは@code{(char-after (point))}と同様である。
しかし、ポイントがバッファの末尾にあると、
@code{following-char}は0を返す。
@c Remember that point is always between characters, and the terminal
@c cursor normally appears over the character following point. Therefore,
@c the character returned by @code{following-char} is the character the
@c cursor is over.
ポイントはつねに文字のあいだにあり、
端末のカーソルはポイントの直後の文字に重ねて表示されることに注意してほしい。
したがって、@code{following-char}が返す文字は、
カーソルが重なっている文字である。
@c In this example, point is between the @samp{a} and the @samp{c}.
つぎの例では、ポイントは@samp{a}と@samp{c}のあいだにある。
@example
@group
---------- Buffer: foo ----------
Gentlemen may cry ``Pea@point{}ce! Peace!,''
but there is no peace.
---------- Buffer: foo ----------
@end group
@group
(char-to-string (preceding-char))
@result{} "a"
(char-to-string (following-char))
@result{} "c"
@end group
@end example
@end defun
@defun preceding-char
@c This function returns the character preceding point in the current
@c buffer. See above, under @code{following-char}, for an example. If
@c point is at the beginning of the buffer, @code{preceding-char} returns
@c 0.
この関数は、カレントバッファのポイントのまえの文字を返す。
例については上記の@code{following-char}を参照。
ポイントがバッファの先頭にあると、@code{preceding-char}は0を返す。
@end defun
@defun bobp
@c This function returns @code{t} if point is at the beginning of the
@c buffer. If narrowing is in effect, this means the beginning of the
@c accessible portion of the text. See also @code{point-min} in
@c @ref{Point}.
この関数は、ポイントがバッファの先頭にあると@code{t}を返す。
ナロイングしていると、これはバッファの参照可能部分の先頭を意味する。
@ref{Point}の@code{point-min}も参照。
@end defun
@defun eobp
@c This function returns @code{t} if point is at the end of the buffer.
@c If narrowing is in effect, this means the end of accessible portion of
@c the text. See also @code{point-max} in @xref{Point}.
この関数は、ポイントがバッファの末尾にあると@code{t}を返す。
ナロイングしていると、これはバッファの参照可能部分の末尾を意味する。
@ref{Point}の@code{point-max}も参照。
@end defun
@defun bolp
@c This function returns @code{t} if point is at the beginning of a line.
@c @xref{Text Lines}. The beginning of the buffer (or of its accessible
@c portion) always counts as the beginning of a line.
この関数は、ポイントが行頭にあると@code{t}を返す。
@pxref{Text Lines}。
バッファ(あるいはその参照可能部分)の先頭は、
つねに行頭とみなす。
@end defun
@defun eolp
@c This function returns @code{t} if point is at the end of a line. The
@c end of the buffer (or of its accessible portion) is always considered
@c the end of a line.
この関数は、ポイントが行末にあると@code{t}を返す。
@pxref{Text Lines}。
バッファ(あるいはその参照可能部分)の末尾は、
つねに行末とみなす。
@end defun
@node Buffer Contents
@c @section Examining Buffer Contents
@section バッファの内容を調べる
@c This section describes two functions that allow a Lisp program to
@c convert any portion of the text in the buffer into a string.
本節では、Lispプログラムでバッファ内の任意の部分のテキストを文字列に変換する
ための2つの関数について述べます。
@defun buffer-substring start end
@c This function returns a string containing a copy of the text of the
@c region defined by positions @var{start} and @var{end} in the current
@c buffer. If the arguments are not positions in the accessible portion of
@c the buffer, @code{buffer-substring} signals an @code{args-out-of-range}
@c error.
この関数は、カレントバッファの@var{start}と@var{end}の位置で定義される
領域のテキストのコピーを含んだ文字列を返す。
引数がバッファの参照可能部分の内側の位置でないと、
@code{buffer-substring}はエラー@code{args-out-of-range}を通知する。
@c It is not necessary for @var{start} to be less than @var{end}; the
@c arguments can be given in either order. But most often the smaller
@c argument is written first.
@var{start}が@var{end}より小さい必要はなく、引数の順番はどちらでもよい。
しかし、ほとんどの場合、小さい引数を先に書く。
@c If the text being copied has any text properties, these are copied into
@c the string along with the characters they belong to. @xref{Text
@c Properties}. However, overlays (@pxref{Overlays}) in the buffer and
@c their properties are ignored, not copied.
コピーされるテキストにテキスト属性がある場合、
テキスト属性もそれが属する文字とともに文字列へコピーされる。
@pxref{Text Properties}。
しかし、バッファのオーバレイ(@pxref{Overlays})とそれらの属性は
無視されコピーされない。
@example
@group
---------- Buffer: foo ----------
This is the contents of buffer foo
---------- Buffer: foo ----------
@end group
@group
(buffer-substring 1 10)
@result{} "This is t"
@end group
@group
(buffer-substring (point-max) 10)
@result{} "he contents of buffer foo
"
@end group
@end example
@end defun
@defun buffer-substring-no-properties start end
@c This is like @code{buffer-substring}, except that it does not copy text
@c properties, just the characters themselves. @xref{Text Properties}.
この関数は@code{buffer-substring}と同様であるが、
テキスト属性をコピーせずに文字だけをコピーする点が異なる。
@pxref{Text Properties}。
@end defun
@defun buffer-string
@c This function returns the contents of the entire accessible portion of
@c the current buffer as a string. It is equivalent to
この関数は、カレントバッファの参照可能部分全体の内容を文字列として返す。
これは、つぎと等価である。
@example
(buffer-substring (point-min) (point-max))
@end example
@example
@group
---------- Buffer: foo ----------
This is the contents of buffer foo
---------- Buffer: foo ----------
(buffer-string)
@result{} "This is the contents of buffer foo
"
@end group
@end example
@end defun
@defun thing-at-point thing
@c Return the @var{thing} around or next to point, as a string.
ポイントの周りやそのうしろにある@var{thing}を文字列として返す。
@c The argument @var{thing} is a symbol which specifies a kind of syntactic
@c entity. Possibilities include @code{symbol}, @code{list}, @code{sexp},
@c @code{defun}, @code{filename}, @code{url}, @code{word}, @code{sentence},
@c @code{whitespace}, @code{line}, @code{page}, and others.
引数@var{thing}は、構文上の要素の種類を指定するシンボルである。
可能な値は、@code{symbol}、@code{list}、@code{sexp}、
@code{defun}、@code{filename}、@code{url}、@code{word}、@code{sentence}、
@code{whitespace}、@code{line}、@code{page}などである。
@example
---------- Buffer: foo ----------
Gentlemen may cry ``Pea@point{}ce! Peace!,''
but there is no peace.
---------- Buffer: foo ----------
(thing-at-point 'word)
@result{} "Peace"
(thing-at-point 'line)
@result{} "Gentlemen may cry ``Peace! Peace!,''\n"
(thing-at-point 'whitespace)
@result{} nil
@end example
@end defun
@node Comparing Text
@c @section Comparing Text
@section テキストの比較
@c @cindex comparing buffer text
@cindex バッファテキストの比較
@c This function lets you compare portions of the text in a buffer, without
@c copying them into strings first.
この関数により、バッファ内のテキストの部分同士を
文字列にコピーせずに比較できます。
@defun compare-buffer-substrings buffer1 start1 end1 buffer2 start2 end2
@c This function lets you compare two substrings of the same buffer or two
@c different buffers. The first three arguments specify one substring,
@c giving a buffer and two positions within the buffer. The last three
@c arguments specify the other substring in the same way. You can use
@c @code{nil} for @var{buffer1}, @var{buffer2}, or both to stand for the
@c current buffer.
この関数は、同一バッファ内の2つの部分文字列、あるいは、
異なる2つのバッファの部分文字列を比較する。
始めの3つの引数は、バッファとそのバッファ内の2つの位置を与え、
1つの部分文字列を指定する。
残りの3つの引数も同様にして別の部分文字列を指定する。
カレントバッファを表すために、
@var{buffer1}と@var{buffer2}のいずれか、あるいは、
両方に@code{nil}を指定できる。
@c The value is negative if the first substring is less, positive if the
@c first is greater, and zero if they are equal. The absolute value of
@c the result is one plus the index of the first differing characters
@c within the substrings.
始めの文字列のほうが小さければ値は負であり、
始めのほうが大きければ値は正であり、等しければ0である。
結果の絶対値は、部分文字列の中で最初に異なる文字の添字足す1である。
@c This function ignores case when comparing characters
@c if @code{case-fold-search} is non-@code{nil}. It always ignores
@c text properties.
この関数は、@code{case-fold-search}が@code{nil}以外であると、
文字の比較では大文字小文字を区別しない。
テキスト属性はつねに無視する。
@c Suppose the current buffer contains the text @samp{foobarbar
@c haha!rara!}; then in this example the two substrings are @samp{rbar }
@c and @samp{rara!}. The value is 2 because the first substring is greater
@c at the second character.
カレントバッファにはテキスト@samp{foobarbar haha!rara!}があるとする。
すると、この例の2つの部分文字列は@samp{rbar }と@samp{rara!}である。
2番目の文字で最初の文字列のほうが大きいので、結果は2である。
@example
(compare-buffer-substring nil 6 11 nil 16 21)
@result{} 2
@end example
@end defun
@node Insertion
@c @section Inserting Text
@section テキストの挿入
@c @cindex insertion of text
@c @cindex text insertion
@cindex テキストの挿入
@cindex 挿入、テキスト
@c @cindex insertion before point
@c @cindex before point, insertion
@cindex ポイントのまえへ挿入
@cindex 挿入、ポイントのまえ
@c @dfn{Insertion} means adding new text to a buffer. The inserted text
@c goes at point---between the character before point and the character
@c after point. Some insertion functions leave point before the inserted
@c text, while other functions leave it after. We call the former
@c insertion @dfn{after point} and the latter insertion @dfn{before point}.
@dfn{挿入}(insertion)とは、バッファに新たなテキストを追加することです。
挿入されたテキストはポイント位置に、つまり、
ポイントのまえの文字とポイントのあとの文字のあいだに入ります。
挿入されたテキストのまえにポイントを留める関数もあれば、
そのうしろに留める関数もあります。
前者を@dfn{ポイントのうしろへ}挿入と呼び、
後者を@dfn{ポイントのまえへ}挿入と呼びます。
@c Insertion relocates markers that point at positions after the
@c insertion point, so that they stay with the surrounding text
@c (@pxref{Markers}). When a marker points at the place of insertion,
@c insertion may or may not relocate the marker, depending on the marker's
@c insertion type (@pxref{Marker Insertion Types}). Certain special
@c functions such as @code{insert-before-markers} relocate all such markers
@c to point after the inserted text, regardless of the markers' insertion
@c type.
挿入により、挿入箇所よりうしろの位置を指すマーカは再配置されて
同じ周りの文字に留まります(@pxref{Markers})。
マーカが挿入箇所を指している場合には、
マーカの挿入型(@pxref{Marker Insertion Types})に依存して、
挿入するとマーカが再配置されたりされなかったりします。
@code{insert-before-markers}などの特定の特殊な関数は、
マーカの挿入型に関わらず、
挿入されたテキストのうしろを指すように
そのようなすべてのマーカを再配置します。
@c Insertion functions signal an error if the current buffer is
@c read-only.
カレントバッファが読み出し専用であると、挿入関数はエラーを通知します。
@c These functions copy text characters from strings and buffers along
@c with their properties. The inserted characters have exactly the same
@c properties as the characters they were copied from. By contrast,
@c characters specified as separate arguments, not part of a string or
@c buffer, inherit their text properties from the neighboring text.
これらの関数は、テキストの文字群をそれらの属性とともに
文字列からバッファへコピーします。
挿入された文字群は、コピーされるまえとまったく同じ属性を持ちます。
対照的に、文字列やバッファの一部ではない孤立した引数として
指定された文字群は、周りのテキストからテキスト属性を継承します。
@c The insertion functions convert text from unibyte to multibyte in
@c order to insert in a multibyte buffer, and vice versa---if the text
@c comes from a string or from a buffer. However, they do not convert
@c unibyte character codes 128 through 255 to multibyte characters, not
@c even if the current buffer is a multibyte buffer. @xref{Converting
@c Representations}.
挿入関数は、文字列由来やバッファ由来のテキストの場合には、
マルチバイトバッファへ挿入するために
ユニバイトからマルチバイトへテキストを変換し、逆向きの変換も行います。
しかし、カレントバッファがたとえマルチバイトバッファであっても、
128から255のユニバイト文字コードはマルチバイト文字には変換しません。
@xref{Converting Representations}。
@defun insert &rest args
@c This function inserts the strings and/or characters @var{args} into the
@c current buffer, at point, moving point forward. In other words, it
@c inserts the text before point. An error is signaled unless all
@c @var{args} are either strings or characters. The value is @code{nil}.
この関数は、文字列や文字群@var{args}をカレントバッファのポイント位置に挿入し、
ポイントを先へ進める。
いいかえれば、ポイントのまえにテキストを挿入する。
@var{args}が文字列でも文字でもないと、エラーを通知する。
値は@code{nil}である。
@end defun
@defun insert-before-markers &rest args
@c This function inserts the strings and/or characters @var{args} into the
@c current buffer, at point, moving point forward. An error is signaled
@c unless all @var{args} are either strings or characters. The value is
@c @code{nil}.
この関数は、文字列や文字群@var{args}をカレントバッファのポイント位置に挿入し、
ポイントを先へ進める。
@var{args}が文字列でも文字でもないと、エラーを通知する。
値は@code{nil}である。
@c This function is unlike the other insertion functions in that it
@c relocates markers initially pointing at the insertion point, to point
@c after the inserted text. If an overlay begins the insertion point, the
@c inserted text falls outside the overlay; if a nonempty overlay ends at
@c the insertion point, the inserted text falls inside that overlay.
挿入箇所を指していたマーカを挿入されたテキストのうしろを指すように再配置
する点で、この関数は他の挿入関数と異なる。
挿入箇所でオーバレイが始まるときには、
挿入されたテキストはオーバレイの範囲外に出る。
空でないオーバレイが挿入箇所で終るときには、
挿入されたテキストはオーバレイの範囲内に入る。
@end defun
@defun insert-char character &optional count inherit
@c This function inserts @var{count} instances of @var{character} into the
@c current buffer before point. The argument @var{count} should be a
@c number (@code{nil} means 1), and @var{character} must be a character.
@c The value is @code{nil}.
この関数は、カレントバッファのポイントのまえに
文字@var{character}を@var{count}個挿入する。
引数@var{count}は数(@code{nil}は1を意味する)であり、
@var{character}は文字であること。
値は@code{nil}である。
@c This function does not convert unibyte character codes 128 through 255
@c to multibyte characters, not even if the current buffer is a multibyte
@c buffer. @xref{Converting Representations}.
この関数は、カレントバッファがたとえマルチバイトバッファであっても、
128から255のユニバイト文字コードはマルチバイト文字には変換しない。
@pxref{Converting Representations}。
@c If @var{inherit} is non-@code{nil}, then the inserted characters inherit
@c sticky text properties from the two characters before and after the
@c insertion point. @xref{Sticky Properties}.
@var{inherit}が@code{nil}以外であると、挿入された文字は、
挿入箇所の前後の2つの文字からスティッキテキスト属性を継承する。
@end defun
@defun insert-buffer-substring from-buffer-or-name &optional start end
@c This function inserts a portion of buffer @var{from-buffer-or-name}
@c (which must already exist) into the current buffer before point. The
@c text inserted is the region from @var{start} and @var{end}. (These
@c arguments default to the beginning and end of the accessible portion of
@c that buffer.) This function returns @code{nil}.
この関数は、バッファ@var{from-buffer-or-name}(既存であること)の部分を
カレントバッファのポイントのまえへ挿入する。
挿入されるテキストは@var{start}から@var{end}までの領域である。
(これらの引数のデフォルトは、当該バッファの参照可能部分の先頭と末尾である。)
この関数は@code{nil}を返す。
@c In this example, the form is executed with buffer @samp{bar} as the
@c current buffer. We assume that buffer @samp{bar} is initially empty.
この例では、バッファ@samp{bar}をカレントバッファとしてフォームを実行する。
バッファ@samp{bar}は最初は空であると仮定する。
@example
@group
---------- Buffer: foo ----------
We hold these truths to be self-evident, that all
---------- Buffer: foo ----------
@end group
@group
(insert-buffer-substring "foo" 1 20)
@result{} nil
---------- Buffer: bar ----------
We hold these truth@point{}
---------- Buffer: bar ----------
@end group
@end example
@end defun
@c @xref{Sticky Properties}, for other insertion functions that inherit
@c text properties from the nearby text in addition to inserting it.
@c Whitespace inserted by indentation functions also inherits text
@c properties.
挿入に加えて周りのテキストからテキスト属性を継承する他の関数については、
@xref{Sticky Properties}。
字下げ関数が挿入した白文字もテキスト属性を継承します。
@node Commands for Insertion
@c @section User-Level Insertion Commands
@section ユーザーレベルの挿入コマンド
@c This section describes higher-level commands for inserting text,
@c commands intended primarily for the user but useful also in Lisp
@c programs.
本節では、テキストを挿入する上位レベルのコマンドについて述べます。
これらはLispプログラムでも有用ですが主にユーザー向けのコマンドです。
@c @deffn Command insert-buffer from-buffer-or-name
@deffn コマンド insert-buffer from-buffer-or-name
@c This command inserts the entire contents of @var{from-buffer-or-name}
@c (which must exist) into the current buffer after point. It leaves
@c the mark after the inserted text. The value is @code{nil}.
このコマンドは、@var{from-buffer-or-name}(既存であること)の全内容を
カレントバッファのポイントのうしろに挿入する。
挿入されたテキストのうしろにマークを置く。
値は@code{nil}である。
@end deffn
@c @deffn Command self-insert-command count
@deffn コマンド self-insert-command count
@c @cindex character insertion
@c @cindex self-insertion
@cindex 文字の挿入
@cindex 自己挿入
@c This command inserts the last character typed; it does so @var{count}
@c times, before point, and returns @code{nil}. Most printing characters
@c are bound to this command. In routine use, @code{self-insert-command}
@c is the most frequently called function in Emacs, but programs rarely use
@c it except to install it on a keymap.
このコマンドは、最後に打たれた文字を挿入する。
ポイントのまえに@var{count}回挿入して@code{nil}を返す。
ほとんどの印字文字はこのコマンドにバインドされている。
普通の状況では、@code{self-insert-command}は
Emacsにおいてもっとも頻繁に呼び出される関数であるが、
プログラムではキーマップに登録する以外にはほとんど使わない。
@c In an interactive call, @var{count} is the numeric prefix argument.
対話的に呼ばれると、@var{count}は数値前置引数である。
@c This command calls @code{auto-fill-function} whenever that is
@c non-@code{nil} and the character inserted is a space or a newline
@c (@pxref{Auto Filling}).
このコマンドは、挿入した文字が空白や改行であると、
@code{auto-fill-function}が@code{nil}以外であると
@code{auto-fill-function}を呼び出す
(@pxref{Auto Filling})。
@c @c Cross refs reworded to prevent overfull hbox. --rjc 15mar92
@c This command performs abbrev expansion if Abbrev mode is enabled and
@c the inserted character does not have word-constituent
@c syntax. (@xref{Abbrevs}, and @ref{Syntax Class Table}.)
このコマンドは、略語(abbrev)モードがオンであり、かつ、
挿入した文字が単語構成構文でないと、略語展開を行う。
(@ref{Abbrevs}と@pxref{Syntax Class Table}。)
@c This is also responsible for calling @code{blink-paren-function} when
@c the inserted character has close parenthesis syntax (@pxref{Blinking}).
挿入した文字が閉じ括弧構文であるときに
@code{blink-paren-function}を呼び出す責任も持つ
(@pxref{Blinking})。
@end deffn
@c @deffn Command newline &optional number-of-newlines
@deffn コマンド newline &optional number-of-newlines
@c This command inserts newlines into the current buffer before point.
@c If @var{number-of-newlines} is supplied, that many newline characters
@c are inserted.
このコマンドは、カレントバッファのポイントのまえに改行を挿入する。
@var{number-of-newlines}を指定すると、その個数だけ改行文字を挿入する。
@c @cindex newline and Auto Fill mode
@cindex 改行と自動詰め込み(auto-fill)モード
@c This function calls @code{auto-fill-function} if the current column
@c number is greater than the value of @code{fill-column} and
@c @var{number-of-newlines} is @code{nil}. Typically what
@c @code{auto-fill-function} does is insert a newline; thus, the overall
@c result in this case is to insert two newlines at different places: one
@c at point, and another earlier in the line. @code{newline} does not
@c auto-fill if @var{number-of-newlines} is non-@code{nil}.
この関数は、現在のコラム番号が@code{fill-column}の値よりも大きく
@var{number-of-newlines}が@code{nil}であると
@code{auto-fill-function}を呼び出す。
@code{auto-fill-function}の典型的な仕事は改行を挿入することである。
ここでの全体としての効果は、改行を2つの異なる位置、つまり、
ポイント位置と行のまえの箇所に挿入することである。
@code{newline}は、@var{number-of-newlines}が@code{nil}以外であると
自動詰め込みを行わない。
@c This command indents to the left margin if that is not zero.
@c @xref{Margins}.
このコマンドは、左端の余白が0以外であるとその分だけ字下げする。
@pxref{Margins}。
@c The value returned is @code{nil}. In an interactive call, @var{count}
@c is the numeric prefix argument.
戻り値は@code{nil}である。
対話的に呼ばれると、@var{count}は数値前置引数である。
@end deffn
@c @deffn Command split-line
@deffn コマンド split-line
@c This command splits the current line, moving the portion of the line
@c after point down vertically so that it is on the next line directly
@c below where it was before. Whitespace is inserted as needed at the
@c beginning of the lower line, using the @code{indent-to} function.
@c @code{split-line} returns the position of point.
このコマンドは、行のポイントのうしろの部分を垂直に降ろして
変更前の真下に行を移動することで現在行を分割する。
関数@code{indent-to}を用いて、降ろした行の先頭に必要に応じて白文字を挿入する。
@c Programs hardly ever use this function.
プログラムではまったくこの関数を使わない。
@end deffn
@defvar overwrite-mode
@c This variable controls whether overwrite mode is in effect. The value
@c should be @code{overwrite-mode-textual}, @code{overwrite-mode-binary},
@c or @code{nil}. @code{overwrite-mode-textual} specifies textual
@c overwrite mode (treats newlines and tabs specially), and
@c @code{overwrite-mode-binary} specifies binary overwrite mode (treats
@c newlines and tabs like any other characters).
この変数は、上書き(overwrite)モードがオンかどうかを制御する。
この値は、@code{overwrite-mode-textual}、@code{overwrite-mode-binary}、
@code{nil}のいずれかであること。
@code{overwrite-mode-textual}は、テキストの上書きモード
(改行とタブを特別に扱う)を指定し、
@code{overwrite-mode-binary}は、バイナリの上書きモード
(改行やタブも他の文字と同様に扱う)を指定する。
@end defvar
@node Deletion
@c @section Deleting Text
@section テキストの削除
@c @cindex deletion vs killing
@cindex 削除とキル
@c Deletion means removing part of the text in a buffer, without saving
@c it in the kill ring (@pxref{The Kill Ring}). Deleted text can't be
@c yanked, but can be reinserted using the undo mechanism (@pxref{Undo}).
@c Some deletion functions do save text in the kill ring in some special
@c cases.
削除とは、バッファ内のテキストのある部分をキルリング
(@pxref{The Kill Ring})に保存せずに取りさることです。
削除したテキストはヤンクはできませんが、
アンドゥ機構(@pxref{Undo})を使って再度挿入できます。
特別な場合にはキルリングにテキストを保存する削除関数もあります。
@c All of the deletion functions operate on the current buffer, and all
@c return a value of @code{nil}.
すべての削除関数はカレントバッファに作用し、@code{nil}の値を返します。
@c @deffn Command erase-buffer
@deffn コマンド erase-buffer
@c This function deletes the entire text of the current buffer, leaving it
@c empty. If the buffer is read-only, it signals a @code{buffer-read-only}
@c error. Otherwise, it deletes the text without asking for any
@c confirmation. It returns @code{nil}.
この関数は、カレントバッファから全テキストを削除して空にする。
バッファが読み出し専用であると、エラー@code{buffer-read-only}を通知する。
さもなければ、いっさい確認を取らずにテキストを削除する。
@code{nil}を返す。
@c Normally, deleting a large amount of text from a buffer inhibits further
@c auto-saving of that buffer ``because it has shrunk''. However,
@c @code{erase-buffer} does not do this, the idea being that the future
@c text is not really related to the former text, and its size should not
@c be compared with that of the former text.
バッファから多量のテキストを削除すると、通常、
『バッファが縮小した』としてそのバッファの自動保存を禁止する。
しかし、@code{erase-buffer}はこうしない。
これまでのテキストと将来のテキストには関連がなく、
これまでのテキストのサイズと比較すべきでないと考えるからである。
@end deffn
@c @deffn Command delete-region start end
@deffn コマンド delete-region start end
@c This command deletes the text in the current buffer in the region
@c defined by @var{start} and @var{end}. The value is @code{nil}. If
@c point was inside the deleted region, its value afterward is @var{start}.
@c Otherwise, point relocates with the surrounding text, as markers do.
このコマンドは、@var{start}と@var{end}で定義されるカレントバッファの
テキストを削除する。
戻り値は@code{nil}である。
削除された領域の内側にポイントがあると、
その値は削除後には@var{start}になる。
さもなければ、マーカと同様にポイントは
周りのテキストに留まるように再配置される。
@end deffn
@c @deffn Command delete-char count &optional killp
@deffn コマンド delete-char count &optional killp
@c This command deletes @var{count} characters directly after point, or
@c before point if @var{count} is negative. If @var{killp} is
@c non-@code{nil}, then it saves the deleted characters in the kill ring.
このコマンドは、ポイントの直後の、あるいは、
@var{count}が負であるとポイントの直前の@var{count}個の文字を削除する。
@var{killp}が@code{nil}以外であると、
削除した文字をキルリングに保存する。
@c In an interactive call, @var{count} is the numeric prefix argument, and
@c @var{killp} is the unprocessed prefix argument. Therefore, if a prefix
@c argument is supplied, the text is saved in the kill ring. If no prefix
@c argument is supplied, then one character is deleted, but not saved in
@c the kill ring.
対話的に呼ばれると、@var{count}は数値前置引数であり、
@var{killp}は未処理の前置引数である。
つまり、前置引数を指定すると、テキストをキルリングに保存する。
前置引数を指定しないと1文字だけを削除するが、
キルリングには保存しない。
@c The value returned is always @code{nil}.
戻り値はつねに@code{nil}である。
@end deffn
@c @deffn Command delete-backward-char count &optional killp
@deffn コマンド delete-backward-char count &optional killp
@c @cindex delete previous char
@cindex 直前の文字を削除
@c This command deletes @var{count} characters directly before point, or
@c after point if @var{count} is negative. If @var{killp} is
@c non-@code{nil}, then it saves the deleted characters in the kill ring.
このコマンドは、ポイントの直前の、あるいは、
@var{count}が負であるとポイントの直後の@var{count}個の文字を削除する。
@var{killp}が@code{nil}以外であると、
削除した文字をキルリングに保存する。
@c In an interactive call, @var{count} is the numeric prefix argument, and
@c @var{killp} is the unprocessed prefix argument. Therefore, if a prefix
@c argument is supplied, the text is saved in the kill ring. If no prefix
@c argument is supplied, then one character is deleted, but not saved in
@c the kill ring.
対話的に呼ばれると、@var{count}は数値前置引数であり、
@var{killp}は未処理の前置引数である。
つまり、前置引数を指定すると、テキストをキルリングに保存する。
前置引数を指定しないと1文字だけを削除するが、
キルリングには保存しない。
@c The value returned is always @code{nil}.
戻り値はつねに@code{nil}である。
@end deffn
@c @deffn Command backward-delete-char-untabify count &optional killp
@deffn コマンド backward-delete-char-untabify count &optional killp
@c @cindex tab deletion
@cindex タブの削除
@c This command deletes @var{count} characters backward, changing tabs
@c into spaces. When the next character to be deleted is a tab, it is
@c first replaced with the proper number of spaces to preserve alignment
@c and then one of those spaces is deleted instead of the tab. If
@c @var{killp} is non-@code{nil}, then the command saves the deleted
@c characters in the kill ring.
このコマンドは、タブを空白にかえながら後向きに@var{count}個の文字を削除する。
つぎに削除する文字がタブであると、まずタブを配置を保つだけの等価な個数の
空白に置換してから、タブのかわりにそれらの空白を削除する。
@var{killp}が@code{nil}以外であると、このコマンドは
削除した文字をキルリングに保存する。
@c Conversion of tabs to spaces happens only if @var{count} is positive.
@c If it is negative, exactly @minus{}@var{count} characters after point
@c are deleted.
@var{count}が正である場合に限って、タブを空白に変換する。
@var{count}が負であると、ポイントのうしろのちょうど
@minus{}@var{count}個の文字を削除する。
@c In an interactive call, @var{count} is the numeric prefix argument, and
@c @var{killp} is the unprocessed prefix argument. Therefore, if a prefix
@c argument is supplied, the text is saved in the kill ring. If no prefix
@c argument is supplied, then one character is deleted, but not saved in
@c the kill ring.
対話的に呼ばれると、@var{count}は数値前置引数であり、
@var{killp}は未処理の前置引数である。
つまり、前置引数を指定すると、テキストをキルリングに保存する。
前置引数を指定しないと1文字だけを削除するが、
キルリングには保存しない。
@c The value returned is always @code{nil}.
戻り値はつねに@code{nil}である。
@end deffn
@defopt backward-delete-char-untabify-method
@tindex backward-delete-char-untabify-method
@c This option specifies how @code{backward-delete-char-untabify} should
@c deal with whitespace. Possible values include @code{untabify}, the
@c default, meaning convert a tab to many spaces and delete one;
@c @code{hungry}, meaning delete all the whitespace characters before point
@c with one command, and @code{nil}, meaning do nothing special for
@c whitespace characters.
このオプションは、@code{backward-delete-char-untabify}での
白文字の扱い方を指定する。
可能な値は、タブを空白に変換してから空白を削除することを意味する
デフォルトの@code{untabify}、
1回の呼び出しでポイントのまえにある白文字をすべて削除することを意味する
@code{hungry}、
白文字に対して特別なことをしないことを意味する@code{nil}である。
@end defopt
@node User-Level Deletion
@c @section User-Level Deletion Commands
@section ユーザーレベルの削除コマンド
@c This section describes higher-level commands for deleting text,
@c commands intended primarily for the user but useful also in Lisp
@c programs.
本節では、テキストを削除する上位レベルのコマンドについて述べます。
これらはLispプログラムでも有用ですが主にユーザー向けのコマンドです。
@c @deffn Command delete-horizontal-space
@deffn コマンド delete-horizontal-space
@c @cindex deleting whitespace
@cindex 白文字の削除
@c This function deletes all spaces and tabs around point. It returns
@c @code{nil}.
この関数は、ポイントの周りの空白やタブをすべて削除する。
@code{nil}を返す。
@c In the following examples, we call @code{delete-horizontal-space} four
@c times, once on each line, with point between the second and third
@c characters on the line each time.
つぎの例では、毎回ポイントを2番目と3番目の文字のあいだに置いて、
各行につき1回ずつ@code{delete-horizontal-space}を計4回呼び出す。
@example
@group
---------- Buffer: foo ----------
I @point{}thought
I @point{} thought
We@point{} thought
Yo@point{}u thought
---------- Buffer: foo ----------
@end group
@group
(delete-horizontal-space) ; @r{Four times.}
@result{} nil
---------- Buffer: foo ----------
Ithought
Ithought
Wethought
You thought
---------- Buffer: foo ----------
@end group
@end example
@end deffn
@c @deffn Command delete-indentation &optional join-following-p
@deffn コマンド delete-indentation &optional join-following-p
@c This function joins the line point is on to the previous line, deleting
@c any whitespace at the join and in some cases replacing it with one
@c space. If @var{join-following-p} is non-@code{nil},
@c @code{delete-indentation} joins this line to the following line
@c instead. The function returns @code{nil}.
この関数は、ポイントがある行をそのまえの行に連結する。
連結箇所の白文字は削除し、場合によっては空白1個に置き換える。
@var{join-following-p}が@code{nil}以外であると、
@code{delete-indentation}は、この行を後続の行に連結する。
関数は@code{nil}を返す。
@c If there is a fill prefix, and the second of the lines being joined
@c starts with the prefix, then @code{delete-indentation} deletes the
@c fill prefix before joining the lines. @xref{Margins}.
詰め込み接頭辞があり、かつ、連結対象の2番目の行が
その接頭辞で始まっている場合には、
@code{delete-indentation}は連結するまえに詰め込み接頭辞を削除する。
@pxref{Margins}。
@c In the example below, point is located on the line starting
@c @samp{events}, and it makes no difference if there are trailing spaces
@c in the preceding line.
以下の例では、ポイントは@samp{events}で始まる行にあり、
そのまえの行の行末に空白があっても違いはない。
@smallexample
@group
---------- Buffer: foo ----------
When in the course of human
@point{} events, it becomes necessary
---------- Buffer: foo ----------
@end group
(delete-indentation)
@result{} nil
@group
---------- Buffer: foo ----------
When in the course of human@point{} events, it becomes necessary
---------- Buffer: foo ----------
@end group
@end smallexample
@c After the lines are joined, the function @code{fixup-whitespace} is
@c responsible for deciding whether to leave a space at the junction.
行を連結したあと、
関数@code{fixup-whitespace}には、
連結箇所に空白を置くかどうかを決定する責任がある。
@end deffn
@defun fixup-whitespace
@c This function replaces all the whitespace surrounding point with either
@c one space or no space, according to the context. It returns @code{nil}.
この関数は、文脈に応じて、
ポイントを囲む白文字すべてを1つの空白に置換するかまったくなくす。
@code{nil}を返す。
@c At the beginning or end of a line, the appropriate amount of space is
@c none. Before a character with close parenthesis syntax, or after a
@c character with open parenthesis or expression-prefix syntax, no space is
@c also appropriate. Otherwise, one space is appropriate. @xref{Syntax
@c Class Table}.
行の先頭や末尾では、空白の適切な量は0である。
閉じ括弧構文の文字のまえや、
開き括弧構文や式前置子構文の文字のうしろでも空白はないほうが適している。
それ以外では、空白1個が適している。
@pxref{Syntax Class Table}。
@c In the example below, @code{fixup-whitespace} is called the first time
@c with point before the word @samp{spaces} in the first line. For the
@c second invocation, point is directly after the @samp{(}.
以下の例では、最初の行の単語@samp{spaces}のまえにポイントがあるときに
最初に@code{fixup-whitespace}が呼ばれる。
2度目に呼ばれるときには、ポイントは@samp{(}の直後にある。
@smallexample
@group
---------- Buffer: foo ----------
This has too many @point{}spaces
This has too many spaces at the start of (@point{} this list)
---------- Buffer: foo ----------
@end group
@group
(fixup-whitespace)
@result{} nil
(fixup-whitespace)
@result{} nil
@end group
@group
---------- Buffer: foo ----------