From 25608044430aecccd0fa47061a78839ec7fe2e9b Mon Sep 17 00:00:00 2001 From: 10sr <8.slashes@gmail.com> Date: Thu, 27 Sep 2018 17:56:33 +0900 Subject: [PATCH] Fix --- emacs.el | 70 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/emacs.el b/emacs.el index d16a5ef..76a02ca 100644 --- a/emacs.el +++ b/emacs.el @@ -1293,6 +1293,42 @@ the list." ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; dired +(defun my-file-head (filename &optional n) + "Return list of first N lines of file FILENAME." + ;; Work with japanese text? + (let ((num (or n 10)) + (size 100) + (beg 0) + (end 0) + (result '())) + (with-temp-buffer + (erase-buffer) + (while (<= (count-lines (point-min) + (point-max)) + num) + (setq end (+ beg size)) + (insert-file-contents-literally filename + nil + beg + end) + (goto-char (point-max)) + (setq beg (+ beg size))) + (goto-char (point-min)) + (while (< (length result) num) + (let ((start (point))) + (forward-line 1) + (setq result + `(,@result ,(buffer-substring-no-properties start + (point)))))) + result + ;; (buffer-substring-no-properties (point-min) + ;; (progn + ;; (forward-line num) + ;; (point))) + ))) +;; (apply 'concat (my-file-head "./shrc" 10) + + (defun my-dired-echo-file-head (arg) "Echo head of current file. @@ -1717,40 +1753,6 @@ This mode is a simplified version of `adoc-mode'." ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defun my-file-head (filename &optional n) - "Return list of first N lines of file FILENAME." - ;; Work with japanese text? - (let ((num (or n 10)) - (size 100) - (beg 0) - (end 0) - (result '())) - (with-temp-buffer - (erase-buffer) - (while (<= (count-lines (point-min) - (point-max)) - num) - (setq end (+ beg size)) - (insert-file-contents-literally filename - nil - beg - end) - (goto-char (point-max)) - (setq beg (+ beg size))) - (goto-char (point-min)) - (while (< (length result) num) - (let ((start (point))) - (forward-line 1) - (setq result - `(,@result ,(buffer-substring-no-properties start - (point)))))) - result - ;; (buffer-substring-no-properties (point-min) - ;; (progn - ;; (forward-line num) - ;; (point))) - ))) -;; (apply 'concat (my-file-head "./shrc" 10) ;; Local Variables: ;; flycheck-disabled-checkers: (emacs-lisp-checkdoc)