]> code.delx.au - gnu-emacs-elpa/blob - packages/yasnippet/snippets/emacs-lisp-mode/x-file.process.yasnippet
Merge commit '0cda39255827f283e7578cd469ae42daad9556a2' from js2-mode
[gnu-emacs-elpa] / packages / yasnippet / snippets / emacs-lisp-mode / x-file.process.yasnippet
1 # contributor: Xah Lee (XahLee.org)
2 # name: a function that process a file
3 # key: x-file
4 # --
5 (defun doThisFile (fpath)
6 "Process the file at path FPATH ..."
7 (let ()
8 ;; create temp buffer without undo record or font lock. (more efficient)
9 ;; first space in temp buff name is necessary
10 (set-buffer (get-buffer-create " myTemp"))
11 (insert-file-contents fpath nil nil nil t)
12
13 ;; process it ...
14 ;; (goto-char 0) ; move to begining of file's content (in case it was open)
15 ;; ... do something here
16 ;; (write-file fpath) ;; write back to the file
17
18 (kill-buffer " myTemp")))