nxml-maint.el 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ;;; nxml-maint.el --- commands for maintainers of nxml-*.el -*- lexical-binding:t -*-
  2. ;; Copyright (C) 2003, 2007-2017 Free Software Foundation, Inc.
  3. ;; Author: James Clark
  4. ;; Keywords: wp, hypermedia, languages, XML
  5. ;; This file is part of GNU Emacs.
  6. ;; GNU Emacs is free software: you can redistribute it and/or modify
  7. ;; it under the terms of the GNU General Public License as published by
  8. ;; the Free Software Foundation, either version 3 of the License, or
  9. ;; (at your option) any later version.
  10. ;; GNU Emacs is distributed in the hope that it will be useful,
  11. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ;; GNU General Public License for more details.
  14. ;; You should have received a copy of the GNU General Public License
  15. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  16. ;;; Commentary:
  17. ;;; Code:
  18. ;;; Parsing target repertoire files from ucs-fonts.
  19. ;; This is for converting the TARGET? files in
  20. ;; http://www.cl.cam.ac.uk/~mgk25/download/ucs-fonts.tar.gz
  21. ;; into a glyph set.
  22. (defun nxml-insert-target-repertoire-glyph-set (file var)
  23. (interactive "fTarget file: \nSVariable name: ")
  24. (let (lst head)
  25. (with-current-buffer (find-file-noselect file)
  26. (goto-char (point-min))
  27. (while (re-search-forward "^ *\\([a-FA-F0-9]\\{2\\}\\)[ \t]+" nil t)
  28. (let ((row (match-string 1))
  29. (eol (line-end-position)))
  30. (while (re-search-forward "\\([a-FA-F0-9]\\{2\\}\\)-\\([a-FA-F0-9]\\{2\\}\\)\\|\\([a-FA-F0-9]\\{2\\}\\)" eol t)
  31. (setq lst
  32. (cons (if (match-beginning 3)
  33. (concat "#x" row (match-string 3))
  34. (concat "(#x" row (match-string 1)
  35. " . #x" row (match-string 2) ")"))
  36. lst))))))
  37. (setq lst (nreverse lst))
  38. (insert (format "(defconst %s\n [" var))
  39. (while lst
  40. (setq head (car lst))
  41. (setq lst (cdr lst))
  42. (insert head)
  43. (when (= (length head) 6)
  44. (while (and lst (= (length (car lst)) 6))
  45. (insert " ")
  46. (insert (car lst))
  47. (setq lst (cdr lst))))
  48. (when lst (insert "\n ")))
  49. (insert "])\n")))
  50. (provide 'nxml-maint)
  51. ;;; nxml-maint.el ends here