diff options
| author | Dave Love | 2002-07-01 20:41:34 +0000 |
|---|---|---|
| committer | Dave Love | 2002-07-01 20:41:34 +0000 |
| commit | a7a75a473e13fb1e3c50367d5a66f112bfcf8ccd (patch) | |
| tree | 8ba24741e9ee279d12270700210fa1c4362349b7 | |
| parent | 56a46d1d74384823528df9b6771dbc40c6a266aa (diff) | |
| download | emacs-a7a75a473e13fb1e3c50367d5a66f112bfcf8ccd.tar.gz emacs-a7a75a473e13fb1e3c50367d5a66f112bfcf8ccd.zip | |
(describe-char-after): Modify display
list processing.
(unicodedata-file, unicodedata-find): New.
| -rw-r--r-- | lisp/international/mule-diag.el | 216 |
1 files changed, 204 insertions, 12 deletions
diff --git a/lisp/international/mule-diag.el b/lisp/international/mule-diag.el index df43eff8972..648efc38f70 100644 --- a/lisp/international/mule-diag.el +++ b/lisp/international/mule-diag.el | |||
| @@ -459,8 +459,15 @@ which font is being used for displaying the character." | |||
| 459 | (encoded (encode-coding-char char coding))) | 459 | (encoded (encode-coding-char char coding))) |
| 460 | (if encoded | 460 | (if encoded |
| 461 | (encoded-string-description encoded coding) | 461 | (encoded-string-description encoded coding) |
| 462 | "not encodable"))))))) | 462 | "not encodable")))) |
| 463 | (setq max-width (apply #'max (mapcar #'(lambda (x) (length (car x))) | 463 | ,@(let ((unicodedata (if (encode-char char 'ucs) |
| 464 | (unicode-data char)))) | ||
| 465 | (if unicodedata | ||
| 466 | (cons (list "Unicode data" " ") unicodedata)))))) | ||
| 467 | (setq max-width (apply #'max (mapcar #'(lambda (x) | ||
| 468 | (if (cadr x) | ||
| 469 | (length (car x)) | ||
| 470 | 0)) | ||
| 464 | item-list))) | 471 | item-list))) |
| 465 | (with-output-to-temp-buffer "*Help*" | 472 | (with-output-to-temp-buffer "*Help*" |
| 466 | (save-excursion | 473 | (save-excursion |
| @@ -468,16 +475,17 @@ which font is being used for displaying the character." | |||
| 468 | (set-buffer-multibyte multibyte-p) | 475 | (set-buffer-multibyte multibyte-p) |
| 469 | (let ((formatter (format "%%%ds:" max-width))) | 476 | (let ((formatter (format "%%%ds:" max-width))) |
| 470 | (dolist (elt item-list) | 477 | (dolist (elt item-list) |
| 471 | (insert (format formatter (car elt))) | 478 | (when (cadr elt) |
| 472 | (dolist (clm (cdr elt)) | 479 | (insert (format formatter (car elt))) |
| 473 | (when (>= (+ (current-column) | 480 | (dolist (clm (cdr elt)) |
| 474 | (or (string-match "\n" clm) | 481 | (when (>= (+ (current-column) |
| 475 | (string-width clm)) 1) | 482 | (or (string-match "\n" clm) |
| 476 | (frame-width)) | 483 | (string-width clm)) 1) |
| 477 | (insert "\n") | 484 | (frame-width)) |
| 478 | (indent-to (1+ max-width))) | 485 | (insert "\n") |
| 479 | (insert " " clm)) | 486 | (indent-to (1+ max-width))) |
| 480 | (insert "\n"))) | 487 | (insert " " clm)) |
| 488 | (insert "\n")))) | ||
| 481 | (when composition | 489 | (when composition |
| 482 | (insert "\nComposed with the following character(s) " | 490 | (insert "\nComposed with the following character(s) " |
| 483 | (mapconcat (lambda (x) (format "`%c'" x)) | 491 | (mapconcat (lambda (x) (format "`%c'" x)) |
| @@ -1218,4 +1226,188 @@ system which uses fontsets)." | |||
| 1218 | (setq fontsets (cdr fontsets))))) | 1226 | (setq fontsets (cdr fontsets))))) |
| 1219 | (print-help-return-message)))) | 1227 | (print-help-return-message)))) |
| 1220 | 1228 | ||
| 1229 | (defcustom unicodedata-file nil | ||
| 1230 | "Location of UnicodeData file. | ||
| 1231 | This is the UnicodeData.txt file from the Unicode consortium, used for | ||
| 1232 | diagnostics. If it is non-nil `describe-char-after' will print data | ||
| 1233 | looked up from it." | ||
| 1234 | :group 'mule | ||
| 1235 | :type '(choice (const :tag "None" nil) | ||
| 1236 | file)) | ||
| 1237 | |||
| 1238 | ;; We could convert the unidata file into a Lispy form once-for-all | ||
| 1239 | ;; and distribute it for loading on demand. It might be made more | ||
| 1240 | ;; space-efficient by splitting strings word-wise and replacing them | ||
| 1241 | ;; with lists of symbols interned in a private obarray, e.g. | ||
| 1242 | ;; "LATIN SMALL LETTER A" => '(LATIN SMALL LETTER A). | ||
| 1243 | (defun unicode-data (char) | ||
| 1244 | "Return a list of Unicode data for unicode CHAR. | ||
| 1245 | Each element is a list of a property description and the property value. | ||
| 1246 | The list is null if CHAR isn't found in `unicodedata-file'." | ||
| 1247 | (if unicodedata-file | ||
| 1248 | (save-excursion | ||
| 1249 | (set-buffer (find-file-noselect unicodedata-file)) | ||
| 1250 | (goto-char (point-min)) | ||
| 1251 | (let ((hex (format "%04X" char)) | ||
| 1252 | found first last) | ||
| 1253 | (if (re-search-forward (concat "^" hex) nil t) | ||
| 1254 | (setq found t) | ||
| 1255 | ;; It's not listed explicitly. Look for ranges, e.g. CJK | ||
| 1256 | ;; ideographs, and check whether it's in one of them. | ||
| 1257 | (while (and (re-search-forward "^\\([^;]+\\);[^;]+First>;" nil t) | ||
| 1258 | (>= char (setq first | ||
| 1259 | (string-to-number (match-string 1) 16))) | ||
| 1260 | (progn | ||
| 1261 | (forward-line 1) | ||
| 1262 | (looking-at "^\\([^;]+\\);[^;]+Last>;") | ||
| 1263 | (> char | ||
| 1264 | (setq last | ||
| 1265 | (string-to-number (match-string 1) 16)))))) | ||
| 1266 | (if (and (>= char first) | ||
| 1267 | (<= char last)) | ||
| 1268 | (setq found t))) | ||
| 1269 | (if found | ||
| 1270 | (let ((fields (mapcar (lambda (elt) | ||
| 1271 | (if (> (length elt) 0) | ||
| 1272 | elt)) | ||
| 1273 | (cdr (split-string | ||
| 1274 | (buffer-substring | ||
| 1275 | (line-beginning-position) | ||
| 1276 | (line-end-position)) | ||
| 1277 | ";"))))) | ||
| 1278 | ;; The length depends on whether the last field was empty. | ||
| 1279 | (unless (or (= 13 (length fields)) | ||
| 1280 | (= 14 (length fields))) | ||
| 1281 | (error "Invalid contents in %s" unicodedata-file)) | ||
| 1282 | ;; The field names and values lists are slightly | ||
| 1283 | ;; modified from Mule-UCS unidata.el. | ||
| 1284 | (list | ||
| 1285 | (list "Name" (let ((name (nth 0 fields))) | ||
| 1286 | ;; Check for <..., First>, <..., Last> | ||
| 1287 | (if (string-match "\\`\\(<[^,]+\\)," name) | ||
| 1288 | (concat (match-string 1 name) ">") | ||
| 1289 | name))) | ||
| 1290 | (list "Category" | ||
| 1291 | (cdr (assoc | ||
| 1292 | (nth 1 fields) | ||
| 1293 | '(("Lu" . "uppercase letter") | ||
| 1294 | ("Ll" . "lowercase letter") | ||
| 1295 | ("Lt" . "titlecase letter") | ||
| 1296 | ("Mn" . "non-spacing mark") | ||
| 1297 | ("Mc" . "spacing-combining mark") | ||
| 1298 | ("Me" . "enclosing mark") | ||
| 1299 | ("Nd" . "decimal digit") | ||
| 1300 | ("Nl" . "letter number") | ||
| 1301 | ("No" . "other number") | ||
| 1302 | ("Zs" . "space separator") | ||
| 1303 | ("Zl" . "line separator") | ||
| 1304 | ("Zp" . "paragraph separator") | ||
| 1305 | ("Cc" . "other control") | ||
| 1306 | ("Cf" . "other format") | ||
| 1307 | ("Cs" . "surrogate") | ||
| 1308 | ("Co" . "private use") | ||
| 1309 | ("Cn" . "not assigned") | ||
| 1310 | ("Lm" . "modifier letter") | ||
| 1311 | ("Lo" . "other letter") | ||
| 1312 | ("Pc" . "connector punctuation") | ||
| 1313 | ("Pd" . "dash punctuation") | ||
| 1314 | ("Ps" . "open punctuation") | ||
| 1315 | ("Pe" . "close punctuation") | ||
| 1316 | ("Pi" . "initial-quotation punctuation") | ||
| 1317 | ("Pf" . "final-quotation punctuation") | ||
| 1318 | ("Po" . "other punctuation") | ||
| 1319 | ("Sm" . "math symbol") | ||
| 1320 | ("Sc" . "currency symbol") | ||
| 1321 | ("Sk" . "modifier symbol") | ||
| 1322 | ("So" . "other symbol"))))) | ||
| 1323 | (list "Combining class" | ||
| 1324 | (cdr (assoc | ||
| 1325 | (string-to-number (nth 2 fields)) | ||
| 1326 | '((0 . "Spacing") | ||
| 1327 | (1 . "Overlays and interior") | ||
| 1328 | (7 . "Nuktas") | ||
| 1329 | (8 . "Hiragana/Katakana voicing marks") | ||
| 1330 | (9 . "Viramas") | ||
| 1331 | (10 . "Start of fixed position classes") | ||
| 1332 | (199 . "End of fixed position classes") | ||
| 1333 | (200 . "Below left attached") | ||
| 1334 | (202 . "Below attached") | ||
| 1335 | (204 . "Below right attached") | ||
| 1336 | (208 . "Left attached (reordrant around \ | ||
| 1337 | single base character)") | ||
| 1338 | (210 . "Right attached") | ||
| 1339 | (212 . "Above left attached") | ||
| 1340 | (214 . "Above attached") | ||
| 1341 | (216 . "Above right attached") | ||
| 1342 | (218 . "Below left") | ||
| 1343 | (220 . "Below") | ||
| 1344 | (222 . "Below right") | ||
| 1345 | (224 . "Left (reordrant around single base \ | ||
| 1346 | character)") | ||
| 1347 | (226 . "Right") | ||
| 1348 | (228 . "Above left") | ||
| 1349 | (230 . "Above") | ||
| 1350 | (232 . "Above right") | ||
| 1351 | (233 . "Double below") | ||
| 1352 | (234 . "Double above") | ||
| 1353 | (240 . "Below (iota subscript)"))))) | ||
| 1354 | (list "Bidi category" | ||
| 1355 | (cdr (assoc | ||
| 1356 | (nth 3 fields) | ||
| 1357 | '(("L" . "Left-to-Right") | ||
| 1358 | ("LRE" . "Left-to-Right Embedding") | ||
| 1359 | ("LRO" . "Left-to-Right Override") | ||
| 1360 | ("R" . "Right-to-Left") | ||
| 1361 | ("AL" . "Right-to-Left Arabic") | ||
| 1362 | ("RLE" . "Right-to-Left Embedding") | ||
| 1363 | ("RLO" . "Right-to-Left Override") | ||
| 1364 | ("PDF" . "Pop Directional Format") | ||
| 1365 | ("EN" . "European Number") | ||
| 1366 | ("ES" . "European Number Separator") | ||
| 1367 | ("ET" . "European Number Terminator") | ||
| 1368 | ("AN" . "Arabic Number") | ||
| 1369 | ("CS" . "Common Number Separator") | ||
| 1370 | ("NSM" . "Non-Spacing Mark") | ||
| 1371 | ("BN" . "Boundary Neutral") | ||
| 1372 | ("B" . "Paragraph Separator") | ||
| 1373 | ("S" . "Segment Separator") | ||
| 1374 | ("WS" . "Whitespace") | ||
| 1375 | ("ON" . "Other Neutrals"))))) | ||
| 1376 | (list "Decomposition" | ||
| 1377 | (if (nth 4 fields) | ||
| 1378 | (let* ((parts (split-string (nth 4 fields))) | ||
| 1379 | (info (car parts))) | ||
| 1380 | (if (string-match "\\`<\\(.+\\)>\\'" info) | ||
| 1381 | (setq info (match-string 1 info)) | ||
| 1382 | (setq info nil)) | ||
| 1383 | (if info (setq parts (cdr parts))) | ||
| 1384 | (setq parts (mapconcat | ||
| 1385 | (lambda (arg) | ||
| 1386 | (string (string-to-number arg 16))) | ||
| 1387 | parts " ")) | ||
| 1388 | (concat info parts)))) | ||
| 1389 | (list "Decimal digit value" | ||
| 1390 | (if (nth 5 fields) | ||
| 1391 | (string-to-number (nth 5 fields)))) | ||
| 1392 | (list "Digit value" | ||
| 1393 | (if (nth 6 fields) | ||
| 1394 | (string-to-number (nth 6 fields)))) | ||
| 1395 | (list "Numeric value" | ||
| 1396 | (if (nth 7 fields) | ||
| 1397 | (string-to-number (nth 6 fields)))) | ||
| 1398 | (list "Mirrored" | ||
| 1399 | (if (equal "Y" (nth 8 fields)) | ||
| 1400 | "yes")) | ||
| 1401 | (list "Old name" (nth 9 fields)) | ||
| 1402 | (list "ISO 10646 comment" (nth 10 fields)) | ||
| 1403 | (list "Uppercase" (and (nth 11 fields) | ||
| 1404 | (string (string-to-number | ||
| 1405 | (nth 11 fields) 16)))) | ||
| 1406 | (list "Lowercase" (and (nth 12 fields) | ||
| 1407 | (string (string-to-number | ||
| 1408 | (nth 12 fields) 16)))) | ||
| 1409 | (list "Titlecase" (and (nth 13 fields) | ||
| 1410 | (string (string-to-number | ||
| 1411 | (nth 13 fields) 16))))))))))) | ||
| 1412 | |||
| 1221 | ;;; mule-diag.el ends here | 1413 | ;;; mule-diag.el ends here |