Mercurial > emacs
comparison lisp/nxml/nxml-maint.el @ 86361:38f93f3d00a2
Initial merge of nxml
author | Mark A. Hershberger <mah@everybody.org> |
---|---|
date | Fri, 23 Nov 2007 06:58:00 +0000 |
parents | |
children | 2ac1a9b70580 |
comparison
equal
deleted
inserted
replaced
86360:aa83d83c27fe | 86361:38f93f3d00a2 |
---|---|
1 ;;; nxml-maint.el --- commands for maintainers of nxml-*.el | |
2 | |
3 ;; Copyright (C) 2003 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: James Clark | |
6 ;; Keywords: XML | |
7 | |
8 ;; This program is free software; you can redistribute it and/or | |
9 ;; modify it under the terms of the GNU General Public License as | |
10 ;; published by the Free Software Foundation; either version 2 of | |
11 ;; the License, or (at your option) any later version. | |
12 | |
13 ;; This program is distributed in the hope that it will be | |
14 ;; useful, but WITHOUT ANY WARRANTY; without even the implied | |
15 ;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | |
16 ;; PURPOSE. See the GNU General Public License for more details. | |
17 | |
18 ;; You should have received a copy of the GNU General Public | |
19 ;; License along with this program; if not, write to the Free | |
20 ;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, | |
21 ;; MA 02111-1307 USA | |
22 | |
23 ;;; Commentary: | |
24 | |
25 ;;; Code: | |
26 | |
27 ;;; Generating files with Unicode char names. | |
28 | |
29 (require 'nxml-uchnm) | |
30 | |
31 (defun nxml-create-unicode-char-name-sets (file) | |
32 "Generate files containing char names from Unicode standard." | |
33 (interactive "fUnicodeData file: ") | |
34 (mapcar (lambda (block) | |
35 (let ((nameset (nxml-unicode-block-char-name-set (nth 0 block)))) | |
36 (save-excursion | |
37 (find-file (concat (get nameset 'nxml-char-name-set-file) | |
38 ".el")) | |
39 (erase-buffer) | |
40 (insert "(nxml-define-char-name-set '") | |
41 (prin1 nameset (current-buffer)) | |
42 (insert "\n '())\n") | |
43 (goto-char (- (point) 3))))) | |
44 nxml-unicode-blocks) | |
45 (save-excursion | |
46 (find-file file) | |
47 (goto-char (point-min)) | |
48 (let ((blocks nxml-unicode-blocks) | |
49 code name) | |
50 (while (re-search-forward "^\\([0-9A-F]+\\);\\([^<;][^;]*\\);" | |
51 nil | |
52 t) | |
53 (setq code (string-to-number (match-string 1) 16)) | |
54 (setq name (match-string 2)) | |
55 (while (and blocks | |
56 (> code (nth 2 (car blocks)))) | |
57 (setq blocks (cdr blocks))) | |
58 (when (and (<= (nth 1 (car blocks)) code) | |
59 (<= code (nth 2 (car blocks)))) | |
60 (save-excursion | |
61 (find-file (concat (get (nxml-unicode-block-char-name-set | |
62 (nth 0 (car blocks))) | |
63 'nxml-char-name-set-file) | |
64 ".el")) | |
65 (insert "(") | |
66 (prin1 name (current-buffer)) | |
67 (insert (format " #x%04X)\n " code)))))))) | |
68 | |
69 ;;; Parsing target repertoire files from ucs-fonts. | |
70 ;; This is for converting the TARGET? files in | |
71 ;; http://www.cl.cam.ac.uk/~mgk25/download/ucs-fonts.tar.gz | |
72 ;; into a glyph set. | |
73 | |
74 (defun nxml-insert-target-repertoire-glyph-set (file var) | |
75 (interactive "fTarget file: \nSVariable name: ") | |
76 (let (lst head) | |
77 (save-excursion | |
78 (set-buffer (find-file-noselect file)) | |
79 (goto-char (point-min)) | |
80 (while (re-search-forward "^ *\\([a-FA-F0-9]\\{2\\}\\)[ \t]+" nil t) | |
81 (let ((row (match-string 1)) | |
82 (eol (save-excursion (end-of-line) (point)))) | |
83 (while (re-search-forward "\\([a-FA-F0-9]\\{2\\}\\)-\\([a-FA-F0-9]\\{2\\}\\)\\|\\([a-FA-F0-9]\\{2\\}\\)" eol t) | |
84 (setq lst | |
85 (cons (if (match-beginning 3) | |
86 (concat "#x" row (match-string 3)) | |
87 (concat "(#x" row (match-string 1) | |
88 " . #x" row (match-string 2) ")")) | |
89 lst)))))) | |
90 (setq lst (nreverse lst)) | |
91 (insert (format "(defconst %s\n [" var)) | |
92 (while lst | |
93 (setq head (car lst)) | |
94 (setq lst (cdr lst)) | |
95 (insert head) | |
96 (when (= (length head) 6) | |
97 (while (and lst (= (length (car lst)) 6)) | |
98 (insert " ") | |
99 (insert (car lst)) | |
100 (setq lst (cdr lst)))) | |
101 (when lst (insert "\n "))) | |
102 (insert "])\n"))) | |
103 | |
104 (provide 'nxml-maint) | |
105 | |
106 ;;; nxml-maint.el ends here |