c-x c-f のなかのひと

17
files.el : C-x C-f みず 2008/6/28 1 / 17

Upload: yuto-hayamizu

Post on 31-May-2015

1.161 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: C-x C-f のなかのひと

files.el : C-x C-fのなかのひと

はやみず

2008/6/28

1 / 17

Page 2: C-x C-f のなかのひと

Emacsを開いてまずすることといえば

2 / 17

Page 3: C-x C-f のなかのひと

C-x C-f

3 / 17

Page 4: C-x C-f のなかのひと

C-x C-f を実行したとき、何がおこっているのか

4 / 17

Page 5: C-x C-f のなかのひと

C-x C-f (find-file) はEmacs Lispで実装されている→ ソースが読める!

5 / 17

Page 6: C-x C-f のなかのひと

C-x C-f

ファイルを開いてるだけでしょ?

そんな難しいことしてないんじゃないの?

6 / 17

Page 7: C-x C-f のなかのひと

C-x C-f

ファイルを開いてるだけでしょ?そんな難しいことしてないんじゃないの?

7 / 17

Page 8: C-x C-f のなかのひと

ファイル処理を司る elisp: files.el

 

約1600行 いろいろ面白いものが埋まっていそうだ

8 / 17

Page 9: C-x C-f のなかのひと

ファイル処理を司る elisp: files.el 

約1600行

 いろいろ面白いものが埋まっていそうだ

9 / 17

Page 10: C-x C-f のなかのひと

ファイル処理を司る elisp: files.el 

約1600行 いろいろ面白いものが埋まっていそうだ

10 / 17

Page 11: C-x C-f のなかのひと

読みはじめるときは

C-h C-k C-x C-fあるいは M-x help k C-x C-f ※ apt-get install emacs22-el などが必要

11 / 17

Page 12: C-x C-f のなかのひと

find-file

(defun find-file (filename &optional wildcards)(interactive (find-file-read-args "Find file: " nil))(let ((value (find-file-noselect filename nil nil wildcards)))(if (listp value)

(mapcar ’switch-to-buffer (nreverse value))(switch-to-buffer value))))

find-file-noselect がキモ

12 / 17

Page 13: C-x C-f のなかのひと

C-h C-f find-file-noselect してみる

Read file FILENAME into a buffer and returnthe buffer. If a buffer exists visiting FILENAME,return that one, but verify that the file has notchanged since visited or saved. The buffer is notselected, just returned to the caller. Optionalsecond arg NOWARN non-nil means suppress anywarning messages. Optional third arg RAWFILEnon-nil means the file is read literally. Optionalfourth arg WILDCARDS non-nil means do wildcardprocessing and visit all the matching files. Whenwildcards are actually used and expanded, return alist of buffers that are visiting the various files.

13 / 17

Page 14: C-x C-f のなかのひと

self-documenting

14 / 17

Page 15: C-x C-f のなかのひと

組み込みドキュメント

Emacs Lispは関数にドキュメントを書けるEmacs標準添付の elispは、ドキュメントが充実 

ソース (実装)の前にドキュメント (意図)を読もう

15 / 17

Page 16: C-x C-f のなかのひと

組み込みドキュメント

Emacs Lispは関数にドキュメントを書けるEmacs標準添付の elispは、ドキュメントが充実 ソース (実装)の前にドキュメント (意図)を読もう

16 / 17

Page 17: C-x C-f のなかのひと

find-file-noselect

17 / 17