aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2004-05-14 05:02:18 +0000
committerStefan Monnier2004-05-14 05:02:18 +0000
commit49c2a2dc4fb062822c9edf9187d73bd6c251e7b9 (patch)
treea0db44a1bb956379940e97b57561bb7d22be97b2
parenta433994a5a3d2bab4c4d659f73b23524201b6819 (diff)
downloademacs-49c2a2dc4fb062822c9edf9187d73bd6c251e7b9.tar.gz
emacs-49c2a2dc4fb062822c9edf9187d73bd6c251e7b9.zip
(describe-char-unicode-data, describe-char-unicodedata-file):
Re-enable the unicode code now that the licensing issues have been cleared in the unicode-4 license. (describe-text-properties-1): Remove unused `overlay' var. (describe-char): Remove unused var `buffer'.
-rw-r--r--lisp/descr-text.el425
1 files changed, 208 insertions, 217 deletions
diff --git a/lisp/descr-text.el b/lisp/descr-text.el
index 61ddf928f7e..75ce294dad6 100644
--- a/lisp/descr-text.el
+++ b/lisp/descr-text.el
@@ -183,7 +183,6 @@ otherwise."
183(defun describe-text-properties-1 (pos output-buffer) 183(defun describe-text-properties-1 (pos output-buffer)
184 (let* ((properties (text-properties-at pos)) 184 (let* ((properties (text-properties-at pos))
185 (overlays (overlays-at pos)) 185 (overlays (overlays-at pos))
186 overlay
187 (wid-field (get-char-property pos 'field)) 186 (wid-field (get-char-property pos 'field))
188 (wid-button (get-char-property pos 'button)) 187 (wid-button (get-char-property pos 'button))
189 (wid-doc (get-char-property pos 'widget-doc)) 188 (wid-doc (get-char-property pos 'widget-doc))
@@ -225,221 +224,214 @@ otherwise."
225 (widget-insert "There are text properties here:\n") 224 (widget-insert "There are text properties here:\n")
226 (describe-property-list properties))))) 225 (describe-property-list properties)))))
227 226
228;;; We cannot use the UnicodeData.txt file as such; it is not free. 227(defcustom describe-char-unicodedata-file nil
229;;; We can turn that info a different format and release the result 228 "Location of Unicode data file.
230;;; as free data. When that is done, we could reinstate the code below. 229This is the UnicodeData.txt file from the Unicode consortium, used for
231;;; For the mean time, here is a dummy placeholder. 230diagnostics. If it is non-nil `describe-char-after' will print data
232;;; -- rms 231looked up from it. This facility is mostly of use to people doing
233(defun describe-char-unicode-data (char) nil) 232multilingual development.
234 233
235;;; (defcustom describe-char-unicodedata-file nil 234This is a fairly large file, not typically present on GNU systems. At
236;;; "Location of Unicode data file. 235the time of writing it is at
237;;; This is the UnicodeData.txt file from the Unicode consortium, used for 236<URL:http://www.unicode.org/Public/UNIDATA/UnicodeData.txt>."
238;;; diagnostics. If it is non-nil `describe-char-after' will print data 237 :group 'mule
239;;; looked up from it. This facility is mostly of use to people doing 238 :version "21.4"
240;;; multilingual development. 239 :type '(choice (const :tag "None" nil)
241 240 file))
242;;; This is a fairly large file, not typically present on GNU systems. At 241
243;;; the time of writing it is at 242;; We could convert the unidata file into a Lispy form once-for-all
244;;; <URL:ftp://www.unicode.org/Public/UNIDATA/UnicodeData.txt>." 243;; and distribute it for loading on demand. It might be made more
245;;; :group 'mule 244;; space-efficient by splitting strings word-wise and replacing them
246;;; :version "21.5" 245;; with lists of symbols interned in a private obarray, e.g.
247;;; :type '(choice (const :tag "None" nil) 246;; "LATIN SMALL LETTER A" => '(LATIN SMALL LETTER A).
248;;; file)) 247
249 248;; Fixme: Check whether this needs updating for Unicode 4.
250;;; ;; We could convert the unidata file into a Lispy form once-for-all 249(defun describe-char-unicode-data (char)
251;;; ;; and distribute it for loading on demand. It might be made more 250 "Return a list of Unicode data for unicode CHAR.
252;;; ;; space-efficient by splitting strings word-wise and replacing them 251Each element is a list of a property description and the property value.
253;;; ;; with lists of symbols interned in a private obarray, e.g. 252The list is null if CHAR isn't found in `describe-char-unicodedata-file'."
254;;; ;; "LATIN SMALL LETTER A" => '(LATIN SMALL LETTER A). 253 (when describe-char-unicodedata-file
255 254 (unless (file-exists-p describe-char-unicodedata-file)
256;;; ;; Fixme: Check whether this needs updating for Unicode 4. 255 (error "`unicodedata-file' %s not found" describe-char-unicodedata-file))
257;;; (defun describe-char-unicode-data (char) 256 (with-current-buffer
258;;; "Return a list of Unicode data for unicode CHAR. 257 ;; Find file in fundamental mode to avoid, e.g. flyspell turned
259;;; Each element is a list of a property description and the property value. 258 ;; on for .txt. Don't use RAWFILE arg in case of DOS line endings.
260;;; The list is null if CHAR isn't found in `describe-char-unicodedata-file'." 259 (let ((auto-mode-alist))
261;;; (when describe-char-unicodedata-file 260 (find-file-noselect describe-char-unicodedata-file))
262;;; (unless (file-exists-p describe-char-unicodedata-file) 261 (goto-char (point-min))
263;;; (error "`unicodedata-file' %s not found" describe-char-unicodedata-file)) 262 (let ((hex (format "%04X" char))
264;;; (save-excursion 263 found first last)
265;;; ;; Find file in fundamental mode to avoid, e.g. flyspell turned 264 (if (re-search-forward (concat "^" hex) nil t)
266;;; ;; on for .txt. Don't use RAWFILE arg in case of DOS line endings. 265 (setq found t)
267;;; (set-buffer (let ((auto-mode-alist)) 266 ;; It's not listed explicitly. Look for ranges, e.g. CJK
268;;; (find-file-noselect describe-char-unicodedata-file))) 267 ;; ideographs, and check whether it's in one of them.
269;;; (goto-char (point-min)) 268 (while (and (re-search-forward "^\\([^;]+\\);[^;]+First>;" nil t)
270;;; (let ((hex (format "%04X" char)) 269 (>= char (setq first
271;;; found first last) 270 (string-to-number (match-string 1) 16)))
272;;; (if (re-search-forward (concat "^" hex) nil t) 271 (progn
273;;; (setq found t) 272 (forward-line 1)
274;;; ;; It's not listed explicitly. Look for ranges, e.g. CJK 273 (looking-at "^\\([^;]+\\);[^;]+Last>;")
275;;; ;; ideographs, and check whether it's in one of them. 274 (> char
276;;; (while (and (re-search-forward "^\\([^;]+\\);[^;]+First>;" nil t) 275 (setq last
277;;; (>= char (setq first 276 (string-to-number (match-string 1) 16))))))
278;;; (string-to-number (match-string 1) 16))) 277 (if (and (>= char first)
279;;; (progn 278 (<= char last))
280;;; (forward-line 1) 279 (setq found t)))
281;;; (looking-at "^\\([^;]+\\);[^;]+Last>;") 280 (if found
282;;; (> char 281 (let ((fields (mapcar (lambda (elt)
283;;; (setq last 282 (if (> (length elt) 0)
284;;; (string-to-number (match-string 1) 16)))))) 283 elt))
285;;; (if (and (>= char first) 284 (cdr (split-string
286;;; (<= char last)) 285 (buffer-substring
287;;; (setq found t))) 286 (line-beginning-position)
288;;; (if found 287 (line-end-position))
289;;; (let ((fields (mapcar (lambda (elt) 288 ";")))))
290;;; (if (> (length elt) 0) 289 ;; The length depends on whether the last field was empty.
291;;; elt)) 290 (unless (or (= 13 (length fields))
292;;; (cdr (split-string 291 (= 14 (length fields)))
293;;; (buffer-substring 292 (error "Invalid contents in %s" describe-char-unicodedata-file))
294;;; (line-beginning-position) 293 ;; The field names and values lists are slightly
295;;; (line-end-position)) 294 ;; modified from Mule-UCS unidata.el.
296;;; ";"))))) 295 (list
297;;; ;; The length depends on whether the last field was empty. 296 (list "Name" (let ((name (nth 0 fields)))
298;;; (unless (or (= 13 (length fields)) 297 ;; Check for <..., First>, <..., Last>
299;;; (= 14 (length fields))) 298 (if (string-match "\\`\\(<[^,]+\\)," name)
300;;; (error "Invalid contents in %s" describe-char-unicodedata-file)) 299 (concat (match-string 1 name) ">")
301;;; ;; The field names and values lists are slightly 300 name)))
302;;; ;; modified from Mule-UCS unidata.el. 301 (list "Category"
303;;; (list 302 (cdr (assoc
304;;; (list "Name" (let ((name (nth 0 fields))) 303 (nth 1 fields)
305;;; ;; Check for <..., First>, <..., Last> 304 '(("Lu" . "uppercase letter")
306;;; (if (string-match "\\`\\(<[^,]+\\)," name) 305 ("Ll" . "lowercase letter")
307;;; (concat (match-string 1 name) ">") 306 ("Lt" . "titlecase letter")
308;;; name))) 307 ("Mn" . "non-spacing mark")
309;;; (list "Category" 308 ("Mc" . "spacing-combining mark")
310;;; (cdr (assoc 309 ("Me" . "enclosing mark")
311;;; (nth 1 fields) 310 ("Nd" . "decimal digit")
312;;; '(("Lu" . "uppercase letter") 311 ("Nl" . "letter number")
313;;; ("Ll" . "lowercase letter") 312 ("No" . "other number")
314;;; ("Lt" . "titlecase letter") 313 ("Zs" . "space separator")
315;;; ("Mn" . "non-spacing mark") 314 ("Zl" . "line separator")
316;;; ("Mc" . "spacing-combining mark") 315 ("Zp" . "paragraph separator")
317;;; ("Me" . "enclosing mark") 316 ("Cc" . "other control")
318;;; ("Nd" . "decimal digit") 317 ("Cf" . "other format")
319;;; ("Nl" . "letter number") 318 ("Cs" . "surrogate")
320;;; ("No" . "other number") 319 ("Co" . "private use")
321;;; ("Zs" . "space separator") 320 ("Cn" . "not assigned")
322;;; ("Zl" . "line separator") 321 ("Lm" . "modifier letter")
323;;; ("Zp" . "paragraph separator") 322 ("Lo" . "other letter")
324;;; ("Cc" . "other control") 323 ("Pc" . "connector punctuation")
325;;; ("Cf" . "other format") 324 ("Pd" . "dash punctuation")
326;;; ("Cs" . "surrogate") 325 ("Ps" . "open punctuation")
327;;; ("Co" . "private use") 326 ("Pe" . "close punctuation")
328;;; ("Cn" . "not assigned") 327 ("Pi" . "initial-quotation punctuation")
329;;; ("Lm" . "modifier letter") 328 ("Pf" . "final-quotation punctuation")
330;;; ("Lo" . "other letter") 329 ("Po" . "other punctuation")
331;;; ("Pc" . "connector punctuation") 330 ("Sm" . "math symbol")
332;;; ("Pd" . "dash punctuation") 331 ("Sc" . "currency symbol")
333;;; ("Ps" . "open punctuation") 332 ("Sk" . "modifier symbol")
334;;; ("Pe" . "close punctuation") 333 ("So" . "other symbol")))))
335;;; ("Pi" . "initial-quotation punctuation") 334 (list "Combining class"
336;;; ("Pf" . "final-quotation punctuation") 335 (cdr (assoc
337;;; ("Po" . "other punctuation") 336 (string-to-number (nth 2 fields))
338;;; ("Sm" . "math symbol") 337 '((0 . "Spacing")
339;;; ("Sc" . "currency symbol") 338 (1 . "Overlays and interior")
340;;; ("Sk" . "modifier symbol") 339 (7 . "Nuktas")
341;;; ("So" . "other symbol"))))) 340 (8 . "Hiragana/Katakana voicing marks")
342;;; (list "Combining class" 341 (9 . "Viramas")
343;;; (cdr (assoc 342 (10 . "Start of fixed position classes")
344;;; (string-to-number (nth 2 fields)) 343 (199 . "End of fixed position classes")
345;;; '((0 . "Spacing") 344 (200 . "Below left attached")
346;;; (1 . "Overlays and interior") 345 (202 . "Below attached")
347;;; (7 . "Nuktas") 346 (204 . "Below right attached")
348;;; (8 . "Hiragana/Katakana voicing marks") 347 (208 . "Left attached (reordrant around \
349;;; (9 . "Viramas") 348single base character)")
350;;; (10 . "Start of fixed position classes") 349 (210 . "Right attached")
351;;; (199 . "End of fixed position classes") 350 (212 . "Above left attached")
352;;; (200 . "Below left attached") 351 (214 . "Above attached")
353;;; (202 . "Below attached") 352 (216 . "Above right attached")
354;;; (204 . "Below right attached") 353 (218 . "Below left")
355;;; (208 . "Left attached (reordrant around \ 354 (220 . "Below")
356;;; single base character)") 355 (222 . "Below right")
357;;; (210 . "Right attached") 356 (224 . "Left (reordrant around single base \
358;;; (212 . "Above left attached") 357character)")
359;;; (214 . "Above attached") 358 (226 . "Right")
360;;; (216 . "Above right attached") 359 (228 . "Above left")
361;;; (218 . "Below left") 360 (230 . "Above")
362;;; (220 . "Below") 361 (232 . "Above right")
363;;; (222 . "Below right") 362 (233 . "Double below")
364;;; (224 . "Left (reordrant around single base \ 363 (234 . "Double above")
365;;; character)") 364 (240 . "Below (iota subscript)")))))
366;;; (226 . "Right") 365 (list "Bidi category"
367;;; (228 . "Above left") 366 (cdr (assoc
368;;; (230 . "Above") 367 (nth 3 fields)
369;;; (232 . "Above right") 368 '(("L" . "Left-to-Right")
370;;; (233 . "Double below") 369 ("LRE" . "Left-to-Right Embedding")
371;;; (234 . "Double above") 370 ("LRO" . "Left-to-Right Override")
372;;; (240 . "Below (iota subscript)"))))) 371 ("R" . "Right-to-Left")
373;;; (list "Bidi category" 372 ("AL" . "Right-to-Left Arabic")
374;;; (cdr (assoc 373 ("RLE" . "Right-to-Left Embedding")
375;;; (nth 3 fields) 374 ("RLO" . "Right-to-Left Override")
376;;; '(("L" . "Left-to-Right") 375 ("PDF" . "Pop Directional Format")
377;;; ("LRE" . "Left-to-Right Embedding") 376 ("EN" . "European Number")
378;;; ("LRO" . "Left-to-Right Override") 377 ("ES" . "European Number Separator")
379;;; ("R" . "Right-to-Left") 378 ("ET" . "European Number Terminator")
380;;; ("AL" . "Right-to-Left Arabic") 379 ("AN" . "Arabic Number")
381;;; ("RLE" . "Right-to-Left Embedding") 380 ("CS" . "Common Number Separator")
382;;; ("RLO" . "Right-to-Left Override") 381 ("NSM" . "Non-Spacing Mark")
383;;; ("PDF" . "Pop Directional Format") 382 ("BN" . "Boundary Neutral")
384;;; ("EN" . "European Number") 383 ("B" . "Paragraph Separator")
385;;; ("ES" . "European Number Separator") 384 ("S" . "Segment Separator")
386;;; ("ET" . "European Number Terminator") 385 ("WS" . "Whitespace")
387;;; ("AN" . "Arabic Number") 386 ("ON" . "Other Neutrals")))))
388;;; ("CS" . "Common Number Separator") 387 (list
389;;; ("NSM" . "Non-Spacing Mark") 388 "Decomposition"
390;;; ("BN" . "Boundary Neutral") 389 (if (nth 4 fields)
391;;; ("B" . "Paragraph Separator") 390 (let* ((parts (split-string (nth 4 fields)))
392;;; ("S" . "Segment Separator") 391 (info (car parts)))
393;;; ("WS" . "Whitespace") 392 (if (string-match "\\`<\\(.+\\)>\\'" info)
394;;; ("ON" . "Other Neutrals"))))) 393 (setq info (match-string 1 info))
395;;; (list 394 (setq info nil))
396;;; "Decomposition" 395 (if info (setq parts (cdr parts)))
397;;; (if (nth 4 fields) 396 ;; Maybe printing ? for unrepresentable unicodes
398;;; (let* ((parts (split-string (nth 4 fields))) 397 ;; here and below should be changed?
399;;; (info (car parts))) 398 (setq parts (mapconcat
400;;; (if (string-match "\\`<\\(.+\\)>\\'" info) 399 (lambda (arg)
401;;; (setq info (match-string 1 info)) 400 (string (or (decode-char
402;;; (setq info nil)) 401 'ucs
403;;; (if info (setq parts (cdr parts))) 402 (string-to-number arg 16))
404;;; ;; Maybe printing ? for unrepresentable unicodes 403 ??)))
405;;; ;; here and below should be changed? 404 parts " "))
406;;; (setq parts (mapconcat 405 (concat info parts))))
407;;; (lambda (arg) 406 (list "Decimal digit value"
408;;; (string (or (decode-char 407 (nth 5 fields))
409;;; 'ucs 408 (list "Digit value"
410;;; (string-to-number arg 16)) 409 (nth 6 fields))
411;;; ??))) 410 (list "Numeric value"
412;;; parts " ")) 411 (nth 7 fields))
413;;; (concat info parts)))) 412 (list "Mirrored"
414;;; (list "Decimal digit value" 413 (if (equal "Y" (nth 8 fields))
415;;; (nth 5 fields)) 414 "yes"))
416;;; (list "Digit value" 415 (list "Old name" (nth 9 fields))
417;;; (nth 6 fields)) 416 (list "ISO 10646 comment" (nth 10 fields))
418;;; (list "Numeric value" 417 (list "Uppercase" (and (nth 11 fields)
419;;; (nth 7 fields)) 418 (string (or (decode-char
420;;; (list "Mirrored" 419 'ucs
421;;; (if (equal "Y" (nth 8 fields)) 420 (string-to-number
422;;; "yes")) 421 (nth 11 fields) 16))
423;;; (list "Old name" (nth 9 fields)) 422 ??))))
424;;; (list "ISO 10646 comment" (nth 10 fields)) 423 (list "Lowercase" (and (nth 12 fields)
425;;; (list "Uppercase" (and (nth 11 fields) 424 (string (or (decode-char
426;;; (string (or (decode-char 425 'ucs
427;;; 'ucs 426 (string-to-number
428;;; (string-to-number 427 (nth 12 fields) 16))
429;;; (nth 11 fields) 16)) 428 ??))))
430;;; ??)))) 429 (list "Titlecase" (and (nth 13 fields)
431;;; (list "Lowercase" (and (nth 12 fields) 430 (string (or (decode-char
432;;; (string (or (decode-char 431 'ucs
433;;; 'ucs 432 (string-to-number
434;;; (string-to-number 433 (nth 13 fields) 16))
435;;; (nth 12 fields) 16)) 434 ??)))))))))))
436;;; ??))))
437;;; (list "Titlecase" (and (nth 13 fields)
438;;; (string (or (decode-char
439;;; 'ucs
440;;; (string-to-number
441;;; (nth 13 fields) 16))
442;;; ??)))))))))))
443 435
444;; Return information about how CHAR is displayed at the buffer 436;; Return information about how CHAR is displayed at the buffer
445;; position POS. If the selected frame is on a graphic display, 437;; position POS. If the selected frame is on a graphic display,
@@ -466,7 +458,6 @@ as well as widgets, buttons, overlays, and text properties."
466 (error "No character follows specified position")) 458 (error "No character follows specified position"))
467 (let* ((char (char-after pos)) 459 (let* ((char (char-after pos))
468 (charset (char-charset char)) 460 (charset (char-charset char))
469 (buffer (current-buffer))
470 (composition (find-composition pos nil nil t)) 461 (composition (find-composition pos nil nil t))
471 (component-chars nil) 462 (component-chars nil)
472 (display-table (or (window-display-table) 463 (display-table (or (window-display-table)