- (if (eq lines t)
- (let ((file (riece-log-get-file identity)))
- (if (file-exists-p file)
- (insert-file-contents file)))
- (let ((files (riece-log-get-files identity))
- (lines (- lines))
- date point)
- (while (and (< lines 0) files)
- (if (and (file-exists-p (car files))
- (string-match (concat "\\([0-9][0-9][0-9][0-9]\\)"
- "\\([0-9][0-9]\\)\\([0-9][0-9]\\).txt$")
- (car files)))
- (save-restriction
- (narrow-to-region (point) (point))
- (setq date (concat " (" (match-string 1 (car files)) "/"
- (match-string 2 (car files)) "/"
- (match-string 3 (car files)) ")"))
- (insert-file-contents (car files))
- (goto-char (point-max))
- (setq lines (forward-line lines))
- (delete-region (point-min) (point))
- (while (not (eobp))
- (end-of-line)
- (insert date)
- (forward-line))
- (goto-char (point-min))))
- (setq files (cdr files))))))
+ (let* (file-name-coding-system
+ default-file-name-coding-system
+ (files (riece-log-list-files identity
+ (if (eq lines t) (current-time))))
+ name coding-system date point)
+ (while (and (or (eq lines t) (> lines 0)) files)
+ (save-restriction
+ (narrow-to-region (point) (point))
+ (if (and (string-match
+ (concat "^" riece-log-file-name-regexp)
+ (setq name (file-name-nondirectory (car files))))
+ (match-beginning 2))
+ (progn
+ (setq coding-system
+ (intern (substring name (match-beginning 2))))
+ (if (featurep 'xemacs)
+ (setq coding-system (find-coding-system coding-system))
+ (unless (coding-system-p coding-system)
+ (setq coding-system nil)))
+ (if coding-system
+ (let ((coding-system-for-read coding-system))
+ (insert-file-contents (car files)))
+ ;;don't insert file contents if they use non
+ ;;supported coding-system.
+ ))
+ ;;if the filename has no coding-system suffix, decode with
+ ;;riece-log-coding-system.
+ (let ((coding-system-for-read riece-log-coding-system))
+ (insert-file-contents (car files))))
+ ;;lines in the file contents are in reversed order.
+ (unless (eq lines t)
+ (goto-char (point-max))
+ (setq lines (- (forward-line (- lines))))
+ (delete-region (point-min) (point)))
+ ;;add (YYYY/MM/dd) suffix on each line left in the current buffer.
+ (unless (equal (substring name 0 8) (format-time-string "%Y%m%d"))
+ (setq date (concat " (" (substring name 0 4) "/"
+ (substring name 4 6) "/"
+ (substring name 6 8) ")"))
+ (while (not (eobp))
+ (end-of-line)
+ (setq point (point))
+ (insert date)
+ (put-text-property point (point)
+ 'riece-overlay-face 'riece-log-date-face)
+ (forward-line))
+ (goto-char (point-min))))
+ (setq files (cdr files)))))