Next: 同時編集からの保護, Previous: バックアップファイル, Up: ファイルの保存 [Contents][Index]
変数require-final-newline
の値がt
のとき、ファイルの保存または書き込みにより、ファイルの終端に改行がないときは、何も尋ねずに改行を追加します。値がvisit
の場合、Emacsはファイルをvisitした直後に、終端に改行がないファイルの改行を追加します(これによりバッファーは変更されたとマークされます。undoはできません)。値がvisit-save
の場合、Emacsはそのような改行をvisitと保存のときに追加します。値がnil
の場合、Emacsはファイルの終端を変更しません。それ以外の非nil
値は、改行を追加するかをEmacsが尋ねることを意味します。デフォルトはnil
です。
ファイルの終端に常に改行があると想定する、特定の種類のファイルのためにデザインされたメジャーモードがいくつかあります。そのようなメジャーモードは、変数require-final-newline
に、変数mode-require-final-newline
の値(デフォルトはt
)をセットします。後者の変数の値をセットすることにより、これらのモードが終端の改行を取り扱う方法を制御できます。
このオプションが非nil
でシンボリックリンクを介してファイルをvisitすると、バッファー保持時にlEmacsはシンボリックリンクを解除して、file-precious-flag
の値が非nil
なら、そのシンボリックリンクと同じ名前のファイルにバッファーを書き込みます(file-precious-flag in The Emacs Lisp Reference
Manualを参照)。シンボリックリンクが指すファイルにバッファーを保存させる(リンクを維持させる)には、変数file-preserve-symlinks-on-save
をt
にカスタマイズしてください。
Normally, when a program writes a file, the operating system briefly caches the file’s data in main memory before committing the data to secondary storage. Although this can greatly improve performance, it risks data loss if the system loses power before committing the cache, and on some platforms other processes might not immediately notice the file’s change.
To lessen this risk, Emacs can invoke the fsync
system call after
saving a file. Using fsync
does not eliminate the risk of data loss
or slow notification, partly because many systems do not support
fsync
properly, and partly because Emacs’s file-saving procedure
typically relies also on directory updates that might not survive a crash
even if fsync
works properly.
The write-region-inhibit-fsync
variable controls whether Emacs
invokes fsync
after saving a file. The variable’s default value is
t
.
Emacsは自動保存ファイルの書き込みにfsync
を使うことはありません。なぜなら、それらのファイルのデータは、いずれにせよ失われるものだからです。