From d0a4292264765b5b79d1eea7968024a50a67cfd6 Mon Sep 17 00:00:00 2001 From: 10sr <8.slashes@gmail.com> Date: Tue, 9 Oct 2018 16:36:29 +0900 Subject: [PATCH] Update head --- emacs.el | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/emacs.el b/emacs.el index 859e897..39f857c 100644 --- a/emacs.el +++ b/emacs.el @@ -1,6 +1,6 @@ ;;; emacs.el --- 10sr emacs initialization -;; Time-stamp: <2018-10-09 15:15:44 JST 10sr> +;; Time-stamp: <2018-10-09 16:36:20 JST 10sr> ;;; Code: @@ -1324,22 +1324,25 @@ found, otherwise returns nil." (defun my-file-head (filename &optional n) "Return list of first N lines of file FILENAME." - ;; Work with japanese text? + ;; TODO: Fix for janapese text + ;; TODO: Fix for short text (let ((num (or n 10)) (size 100) (beg 0) (end 0) - (result '())) + (result '()) + (read -1)) (with-temp-buffer (erase-buffer) - (while (<= (count-lines (point-min) - (point-max)) - num) + (while (or (<= (count-lines (point-min) + (point-max)) + num) + (eq read 0)) (setq end (+ beg size)) - (insert-file-contents-literally filename - nil - beg - end) + (setq read (nth 1 (insert-file-contents-literally filename + nil + beg + end))) (goto-char (point-max)) (setq beg (+ beg size))) (goto-char (point-min))