[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bep] dired-do-shell-command (learning lisp)
- To: bep@argv.org
- Subject: Re: [bep] dired-do-shell-command (learning lisp)
- From: Reiko TAKAHASHI <HFC03614@nifty.ne.jp> (高橋玲子)
- Date: Sun, 17 Jun 2001 20:39:52 +0900
- Delivered-To: mailing list bep@argv.org
- Mailing-List: contact bep-help@argv.org; run by ezmlm
r高橋です。
Reply Koichi INOUE <inoue@...>'s message:
} call-processは子プロセスを起動して作業させる時に使う関数です。
} 引数の意味はC-h f call-process
----------
call-process is a built-in function.
Call PROGRAM synchronously in separate process.
The remaining arguments are optional.
The program's input comes from file INFILE (nil means `/dev/null').
----------
/dev/null は、DOSでいったら <nul (なんてできるかどうか知らないけど……)
みたいな雰囲気でしょうか?
----------
Insert output in BUFFER before point; t means current buffer;
nil for BUFFER means discard it; 0 means discard and don't wait.
BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case,
REAL-BUFFER says what to do with standard output, as above,
while STDERR-FILE says what to do with standard error in the child.
STDERR-FILE may be nil (discard standard error output),
t (mix it with ordinary output), or a file name string.
Fourth arg DISPLAY non-nil means redisplay buffer as output is inserted.
----------
↑は全然わからないのですが、ひとまずわからなくてもいいですか?(^.^)
----------
Remaining arguments are strings passed as command arguments to PROGRAM.
If BUFFER is 0, `call-process' returns immediately with value nil.
Otherwise it waits for PROGRAM to terminate
and returns a numeric exit status or a signal description string.
If you quit, the process is killed with SIGINT, or SIGKILL if you quit a
gain.
----------
↑はわかっていたほうがよさそう……でしょうか?
BUFFER is 0 の意味は……引数がなかったら(nil だったら?)ということです
か???
やはり、GRの点字表示モードをEmacsの中から制御したいなと思っています。
でも、難しそうな気配……?
(call-process gr nil nil nil -g1 nil)
に、(defun ...(でなにかの名前を付けて、それになにかのキーを割り当てて……
のような手順でできるでしょうか?
} > delete-directory 関数では、今作ったばかりの delete-directory-recursive 関
} > 数を使っているんですよね?
} > これを、.emacs(???)に書き込んでディレクトリの削除をしたい場合、M-x delet
} > e-directory とすることになるんでしょうか?
}
} ここですが、diredでDマークをつけてxを押したとき、diredはそれぞれのファイ
} ルに対して、
} ディレクトリだったらdelete-directoryを
} 普通のファイルだったら delete-fileを
} みたいなことをします。
} (本当はもうちょっと複雑ですが)
なるほど! でも……、だったら↓は、なぜ interactive なんでしょう?
もしかして、"s"に秘密があるのでしょうか。
;;; diredでディレクトリを削除
(add-hook 'dired-mode-hook
'(lambda ()
(defun delete-directory-recursive (dir)
(interactive "s")
(call-process "deltree" nil nil nil "-y" dir))
(defun delete-directory (dir)
(interactive "s")
(delete-directory-recursive dir))))
} そして、本来delete-directoryはEmacsに元々ある関数で、引数が一つあり、
} 「引数で指定したディレクトリの中身が空だったらそのディレクトリを削除する」
} というものです。
} これを、坂本さんの例ではdeltreeコマンドやrmコマンドを起動してなにがなん
} でもばさっと消す関数に定義し直しているのです。
} このように、最初からある関数でも.emacsで動作を変更できてしまうところがお
} もしろいと思いませんか?
はい、思います(^_^)。
**-***-***-***-***-***-***-***-***-***-***-***-**
Reiko TAKAHASHI (高橋玲子)
E-mail: HFC03614@...
ICQ UIN: 85924121 (Twinkle)
**-***-***-***-***-***-***-***-***-***-***-***-**