複数のファイルのペアをマージしたい場合があります。たとえば、fileA.oldとfileA.new、fileB.oldとfileB.new ..などをマージしたいとします。現在、emacsを開く必要があります。最初のファイルの名前、リターンキー、2番目のファイルの名前、リターンキーを入力し、マージモードでimを入力しますM-x ediff-merge-files
...両方のファイル名を引数としてemacsを起動し、マージモードで起動する方法はありますか?
1 に答える
3
コマンドラインからLispコードをEmacsに渡すことができます。
emacs --eval '(ediff-merge-files "path/to/file1" "path/to/file2")'
もちろん、これをスクリプトでラップして、呼び出しをより便利にすることもできます。たとえば、Bourneシェルでは、次のような単純なバージョンを実行できます。
#!/bin/sh
# check correct invocation
if [ $# != 2 ]; then
echo "USAGE: $(basename "${0}") <file1> <file2>"
exit 1
fi
# check that file1 exists and is readable
if [ -f "${1}" ]; then
if [ ! -r "${1}" ]; then
echo "Cannot open '${1}', access denied."
exit 3
fi
else
echo "File not found: '${1}'"
exit 2
fi
# check that file2 exists and is readable
if [ -f "${2}" ]; then
if [ ! -r "${2}" ]; then
echo "Cannot open '${2}', access denied."
exit 5
fi
else
echo "File not found: '${2}'"
exit 4
fi
# invoke emacs
emacs --eval "(ediff-merge-files \"${1}\" \"${2}\")"
これをのファイルediff
に保存する$PATH
と、次のように書くことができます。
ediff file1 file2
コマンドラインで、Emacsはで指定された2つのファイルをポップアップ表示しますediff-mode
。
于 2012-11-09T22:45:13.593 に答える