Mercurial > emacs
changeset 53156:4d79ab10fd56
(make-mms-derivative-load-edits-file): Rewrite
to avoid external programs; do all processing inside Emacs.
author | Thien-Thi Nguyen <ttn@gnuvola.org> |
---|---|
date | Tue, 25 Nov 2003 02:47:22 +0000 |
parents | 384390a9b30f |
children | 0ddc9f5e0a3c |
files | vms/make-mms-derivative.el |
diffstat | 1 files changed, 23 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/vms/make-mms-derivative.el Mon Nov 24 22:23:52 2003 +0000 +++ b/vms/make-mms-derivative.el Tue Nov 25 02:47:22 2003 +0000 @@ -79,16 +79,29 @@ (defun make-mms-derivative-load-edits-file (name) (make-mms-derivative-data 'edits-filename name) - (let ((i 0) tmp res) - (while (progn - (setq tmp - (shell-command-to-string - (format "grep '^;;;%s;;' %s | sed 's/^;;;[0-9][0-9]*;;//g'" - i name))) - (not (string= "" tmp))) - (setq res (cons (cons i tmp) res) - i (1+ i))) - (make-mms-derivative-data 'raw-data res)) + (let (raw-data + (cur (current-buffer)) + (wbuf (get-buffer-create "*make-mms-derivative-load-edits-file work"))) + (set-buffer wbuf) + (insert-file-contents name) + (keep-lines "^;;;[0-9]+;;") + (goto-char (point-max)) + (while (re-search-backward "^;;;\\([0-9]+\\);;\\(.*\\)$" (point-min) t) + (let* ((i (string-to-number (match-string 1))) + (line (match-string 2)) + (look (assq i raw-data))) + (if look + (setcdr look (cons line (cdr look))) + (setq raw-data (cons (list i line) raw-data))))) + (kill-buffer wbuf) + (set-buffer cur) + (mapcar '(lambda (ent) + (setcdr ent (mapconcat '(lambda (line) + (concat line "\n")) + (cdr ent) + ""))) + raw-data) + (make-mms-derivative-data 'raw-data raw-data)) (load name)) (defun make-mms-derivative-insert-raw-data (n)