瀏覽代碼

Fix

master
10sr 6 年之前
父節點
當前提交
2560804443
簽署人: 10sr GPG 金鑰 ID: 7BEC428194130EB2
共有 1 個檔案被更改,包括 36 行新增34 行删除
  1. +36
    -34
      emacs.el

+ 36
- 34
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)


Loading…
取消
儲存