Mercurial > hg > xemacs-beta
diff lisp/descr-text.el @ 5186:b36d089cbed5
Don't error if describe-char-use-cache t and database not readable, descr-text
2010-04-02 Aidan Kehoe <kehoea@parhasard.net>
* descr-text.el (describe-char-unicode-data):
Don't give up if describe-char-use-cache is t and the database
isn't readable, warn and insert the entire UnicodeData.txt file
instead.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Fri, 02 Apr 2010 13:23:31 +0100 |
parents | b50624d3ae55 |
children | 09f8ed0933c7 |
line wrap: on
line diff
--- a/lisp/descr-text.el Fri Apr 02 12:39:33 2010 +0100 +++ b/lisp/descr-text.el Fri Apr 02 13:23:31 2010 +0100 @@ -686,52 +686,54 @@ (when (characterp char) (setq char (encode-char char 'ucs))) (with-temp-buffer - (if describe-char-use-cache - ;; Use the database info. - (let ((database-handle (open-database - (unidata-generate-database-file-name - describe-char-unicodedata-file - (eighth (file-attributes - describe-char-unicodedata-file)) - unidata-database-format) - unidata-database-format - nil "r" - #o644 'no-conversion-unix)) - (coding-system-for-read 'no-conversion-unix) - key lookup) - (unless database-handle - (error 'io-error - (format "Could not open %s as a %s database" - (unidata-generate-database-file-name - describe-char-unicodedata-file - (eighth (file-attributes - describe-char-unicodedata-file)) - unidata-database-format) - unidata-database-format))) - (setq key (format "%04X" char) - lookup (get-database key database-handle)) - (if lookup - ;; Okay, we have information on that character in particular. - (progn (setq lookup (read lookup)) - (insert-file-contents describe-char-unicodedata-file nil - (first lookup) (second lookup))) - ;; No information on that character in particular. Do we have - ;; range information? If so, load and check for our desired - ;; character. - (setq lookup (get-database "range-information" database-handle) - lookup (if lookup (read lookup)) - lookup (if lookup (get-range-table char lookup))) - (when lookup - (insert-file-contents describe-char-unicodedata-file nil - (first lookup) (second lookup)))) - (close-database database-handle)) - - ;; Otherwise, insert the whole file (the FSF approach). - (set-buffer (get-buffer-create " *Unicode Data*")) - (when (zerop (buffer-size)) - ;; Don't use -literally in case of DOS line endings. - (insert-file-contents describe-char-unicodedata-file))) - + (let ((coding-system-for-read coding-system-for-read) + database-handle key lookup) + (if (and describe-char-use-cache + (prog1 + (setq database-handle + (open-database + (unidata-generate-database-file-name + describe-char-unicodedata-file + (eighth (file-attributes + describe-char-unicodedata-file)) + unidata-database-format) + unidata-database-format + nil "r" + #o644 'no-conversion-unix)) + (unless database-handle + (warn "Could not open %s as a %s database" + (unidata-generate-database-file-name + describe-char-unicodedata-file + (eighth (file-attributes + describe-char-unicodedata-file)) + unidata-database-format) + unidata-database-format)))) + (progn + ;; Use the database info. + (setq coding-system-for-read 'no-conversion-unix + key (format "%04X" char) + lookup (get-database key database-handle)) + (if lookup + ;; Okay, we have information on that character in particular. + (progn (setq lookup (read lookup)) + (insert-file-contents describe-char-unicodedata-file + nil (first lookup) + (second lookup))) + ;; No information on that character in particular. Do we + ;; have range information? If so, load and check for our + ;; desired character. + (setq lookup (get-database "range-information" database-handle) + lookup (if lookup (read lookup)) + lookup (if lookup (get-range-table char lookup))) + (when lookup + (insert-file-contents describe-char-unicodedata-file nil + (first lookup) (second lookup)))) + (close-database database-handle)) + ;; Otherwise, insert the whole file (the FSF approach). + (set-buffer (get-buffer-create " *Unicode Data*")) + (when (zerop (buffer-size)) + ;; Don't use -literally in case of DOS line endings. + (insert-file-contents describe-char-unicodedata-file)))) (goto-char (point-min)) (let ((hex (format "%04X" char)) found first last unihan-match unihan-info unihan-database-handle