Browse Source

Fix

master
10sr 6 years ago
parent
commit
2560804443
Signed by: 10sr GPG Key ID: 7BEC428194130EB2
1 changed files with 36 additions and 34 deletions
  1. +36
    -34
      emacs.el

+ 36
- 34
emacs.el View File

@@ -1293,6 +1293,42 @@ the list."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; dired ;; 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) (defun my-dired-echo-file-head (arg)
"Echo head of current file. "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: ;; Local Variables:
;; flycheck-disabled-checkers: (emacs-lisp-checkdoc) ;; flycheck-disabled-checkers: (emacs-lisp-checkdoc)


Loading…
Cancel
Save