1 | ;;; nt-file.el --- file-related functions |
---|
2 | ;; |
---|
3 | ;; Copyright (C) 2005-2009 naoya_t. All Rights Reserved. |
---|
4 | ;; |
---|
5 | ;; Author: naoya_t <naoya.t@aqua.plala.or.jp> |
---|
6 | ;; Maintainer: naoya_t <naoya.t@aqua.plala.or.jp> |
---|
7 | ;; Primary distribution site: |
---|
8 | ;; http://lambdarepos.svnrepository.com/svn/share/lang/elisp/pdicv-mode/trunk |
---|
9 | ;; |
---|
10 | ;; Created: 16 Feb 2005 (formerly nt-utils) |
---|
11 | ;; Last modified: 15 Dec 2005 |
---|
12 | ;; Version: 1.0 |
---|
13 | ;; Keywords: read-from-file |
---|
14 | |
---|
15 | (provide 'nt-file) |
---|
16 | |
---|
17 | ;;; Commentary: |
---|
18 | |
---|
19 | ; (read-from-file FNAME FROM LENGTH) |
---|
20 | ; - �ե�����NAME �Ρ��Ƭ�������FROM ���� LENGTH �Х���������ʸ������֤��� |
---|
21 | |
---|
22 | ; (scan-latest-version PATHNAME-FMT MIN MAX) |
---|
23 | ; - �ե����ޥå�PATHNAME-FMT �ǻ�ꤵ�줿�ѥ�̾�Υե���������; �С�������椬 MIN �ʾ�AX �ʲ���ϰ���Ǥ������������ |
---|
24 | ; (�) (scan-latest-version "EIJIRO%d.DIC" 50 100) |
---|
25 | ; - ���Ĥ������� nil ����� |
---|
26 | |
---|
27 | ;;; Code: |
---|
28 | (defun nt:read-from-file (filename read-from read-length) |
---|
29 | "read a part of file" |
---|
30 | (save-current-buffer |
---|
31 | (let ((buffer-name (generate-new-buffer-name "*read-from-file*")) |
---|
32 | (my-buffer nil)) |
---|
33 | (generate-new-buffer buffer-name) |
---|
34 | (set-buffer buffer-name) |
---|
35 | (insert-file-contents-literally filename nil read-from (+ read-from read-length) nil) |
---|
36 | ; (setq buffer-read-only t) |
---|
37 | (setq my-buffer (buffer-substring 1 (+ 1 read-length))) |
---|
38 | (kill-buffer buffer-name) |
---|
39 | my-buffer))) |
---|
40 | |
---|
41 | (defun nt:scan-latest-version (filename-format min max) |
---|
42 | (catch 'scan-latest-version |
---|
43 | (let ((version max)) |
---|
44 | (while (>= version min) |
---|
45 | (let ((file (format filename-format version))) |
---|
46 | (if (file-readable-p file) (throw 'scan-latest-version (list file version)) |
---|
47 | (setq version (1- version))))) |
---|
48 | nil))) |
---|
49 | |
---|
50 | ;;; nt-file.el ends here |
---|