Kaynağa Gözat

WIP Add my-file-head

master
10sr 6 yıl önce
ebeveyn
işleme
dd4714864b
İmzalayan: 10sr GPG Anahtar Kimliği: 7BEC428194130EB2
1 değiştirilmiş dosya ile 28 ekleme ve 1 silme
  1. +28
    -1
      emacs.el

+ 28
- 1
emacs.el Dosyayı Görüntüle

@@ -1563,4 +1563,31 @@ This mode is a simplified version of `adoc-mode'."
(buffer-substring-no-properties (point-min) (point-max))))
))

;;; emacs.el ends here
(defun my-file-head (filename &optional n)
"Return list of first N lines of file FILENAME."
(let ((num (or n 10))
(size 100)
(beg 0)
(end 0)
(result '()))
(with-temp-buffer
(while (<= (count-lines (point-min)
(point-max))
num)
(setq end (+ beg size))
(insert-file-contents filename
nil
beg
end)
(setq beg end))
(goto-char (point-min))
(while (< (length result) num)
(let ((start (point)))
(forward-line 1)
(setq result
`(,@result ,(buffer-substring-no-properties start
(point))))))
result)))
;; (apply 'concat (car (my-file-head "./emacs.el"))

;;; emancs.el ends here

Yükleniyor…
İptal
Kaydet