annotate lisp/descr-text.el @ 111012:2b6e7f137773

Fix the MSDOS build broken by last revisions. msdos/sed1v2.inp: Use $(..) instead of ${..} in all edit commands. Needed because of changes in revno 101897. msdos/sed6.inp (mkinfodir): Edit to avoid Unix shell-isms. Needed because of changes in revno 101876. src/unexcoff.c (make_hdr): Fix prototype according to changes in revno 101757.
author Eli Zaretskii <eliz@gnu.org>
date Fri, 15 Oct 2010 20:45:12 +0200
parents 60516122d066
children 417b1e4d63cd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45057
1344a9d40dc8 Follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 45022
diff changeset
1 ;;; descr-text.el --- describe text mode
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
64762
41bb365f41c4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64636
diff changeset
3 ;; Copyright (C) 1994, 1995, 1996, 2001, 2002, 2003, 2004,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 106320
diff changeset
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Author: Boris Goldowsky <boris@gnu.org>
67752
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
7 ;; Maintainer: FSF
59752
719482868b87 Add more keywords.
Eli Zaretskii <eliz@gnu.org>
parents: 58994
diff changeset
8 ;; Keywords: faces, i18n, Unicode, multilingual
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94147
diff changeset
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94147
diff changeset
14 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94147
diff changeset
15 ;; (at your option) any later version.
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94147
diff changeset
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;; Describe-Text Mode.
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;;; Code:
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30
67814
cc79e7966f97 2005-12-27 Nick Roberts <nickrob@snap.net.nz>
Nick Roberts <nickrob@snap.net.nz>
parents: 67752
diff changeset
31 (eval-when-compile (require 'quail))
105850
788b904aa868 Require help-mode rather than help-fns (bug#4861).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 105372
diff changeset
32 (require 'help-mode)
51127
d68739c97632 (unicodedata-file): New.
Dave Love <fx@gnu.org>
parents: 49588
diff changeset
33
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;;; Describe-Text Utilities.
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 (defun describe-text-widget (widget)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 "Insert text to describe WIDGET in the current buffer."
67752
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
38 (insert-text-button
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
39 (symbol-name (if (symbolp widget) widget (car widget)))
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
40 'action `(lambda (&rest ignore)
67814
cc79e7966f97 2005-12-27 Nick Roberts <nickrob@snap.net.nz>
Nick Roberts <nickrob@snap.net.nz>
parents: 67752
diff changeset
41 (widget-browse ',widget))
cc79e7966f97 2005-12-27 Nick Roberts <nickrob@snap.net.nz>
Nick Roberts <nickrob@snap.net.nz>
parents: 67752
diff changeset
42 'help-echo "mouse-2, RET: browse this widget")
67752
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
43 (insert " ")
67814
cc79e7966f97 2005-12-27 Nick Roberts <nickrob@snap.net.nz>
Nick Roberts <nickrob@snap.net.nz>
parents: 67752
diff changeset
44 (insert-text-button
cc79e7966f97 2005-12-27 Nick Roberts <nickrob@snap.net.nz>
Nick Roberts <nickrob@snap.net.nz>
parents: 67752
diff changeset
45 "(widget)Top" 'type 'help-info 'help-args '("(widget)Top")))
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 (defun describe-text-sexp (sexp)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 "Insert a short description of SEXP in the current buffer."
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 (let ((pp (condition-case signal
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 (pp-to-string sexp)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 (error (prin1-to-string signal)))))
95455
a11e3f3131cc (describe-text-sexp): Use `string-match-p'. Simplify.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
52 (when (string-match-p "\n\\'" pp)
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 (setq pp (substring pp 0 (1- (length pp)))))
95455
a11e3f3131cc (describe-text-sexp): Use `string-match-p'. Simplify.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
54
a11e3f3131cc (describe-text-sexp): Use `string-match-p'. Simplify.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
55 (if (and (not (string-match-p "\n" pp))
a11e3f3131cc (describe-text-sexp): Use `string-match-p'. Simplify.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
56 (<= (length pp) (- (window-width) (current-column))))
67752
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
57 (insert pp)
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
58 (insert-text-button
67865
f94acc1b8bc2 (describe-text-sexp): Use square brackets for
Juri Linkov <juri@jurta.org>
parents: 67855
diff changeset
59 "[Show]" 'action `(lambda (&rest ignore)
95455
a11e3f3131cc (describe-text-sexp): Use `string-match-p'. Simplify.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
60 (with-output-to-temp-buffer
a11e3f3131cc (describe-text-sexp): Use `string-match-p'. Simplify.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
61 "*Pp Eval Output*"
a11e3f3131cc (describe-text-sexp): Use `string-match-p'. Simplify.
Juanma Barranquero <lekktu@gmail.com>
parents: 94678
diff changeset
62 (princ ',pp)))
67752
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
63 'help-echo "mouse-2, RET: pretty print value in another buffer"))))
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
65 (defun describe-property-list (properties)
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 "Insert a description of PROPERTIES in the current buffer.
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 PROPERTIES should be a list of overlay or text properties.
54686
d74ae0505dad (describe-property-list): Add `font-lock-face'.
Juri Linkov <juri@jurta.org>
parents: 54545
diff changeset
68 The `category', `face' and `font-lock-face' properties are made
67752
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
69 into help buttons that call `describe-text-category' or
54686
d74ae0505dad (describe-property-list): Add `font-lock-face'.
Juri Linkov <juri@jurta.org>
parents: 54545
diff changeset
70 `describe-face' when pushed."
45697
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
71 ;; Sort the properties by the size of their value.
58994
720c9b9bf376 (describe-property-list): Don't treat syntax-table
Juri Linkov <juri@jurta.org>
parents: 58416
diff changeset
72 (dolist (elt (sort (let (ret)
45697
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
73 (while properties
58994
720c9b9bf376 (describe-property-list): Don't treat syntax-table
Juri Linkov <juri@jurta.org>
parents: 58416
diff changeset
74 (push (list (pop properties) (pop properties)) ret))
45697
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
75 ret)
65376
22f4c45c6f2f (describe-property-list): Handle non-symbol prop names.
Richard M. Stallman <rms@gnu.org>
parents: 64762
diff changeset
76 (lambda (a b) (string< (prin1-to-string (nth 0 a) t)
22f4c45c6f2f (describe-property-list): Handle non-symbol prop names.
Richard M. Stallman <rms@gnu.org>
parents: 64762
diff changeset
77 (prin1-to-string (nth 0 b) t)))))
45697
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
78 (let ((key (nth 0 elt))
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
79 (value (nth 1 elt)))
67752
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
80 (insert (propertize (format " %-20s " key)
67814
cc79e7966f97 2005-12-27 Nick Roberts <nickrob@snap.net.nz>
Nick Roberts <nickrob@snap.net.nz>
parents: 67752
diff changeset
81 'face 'help-argument-name))
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (cond ((eq key 'category)
67814
cc79e7966f97 2005-12-27 Nick Roberts <nickrob@snap.net.nz>
Nick Roberts <nickrob@snap.net.nz>
parents: 67752
diff changeset
83 (insert-text-button
cc79e7966f97 2005-12-27 Nick Roberts <nickrob@snap.net.nz>
Nick Roberts <nickrob@snap.net.nz>
parents: 67752
diff changeset
84 (symbol-name value)
cc79e7966f97 2005-12-27 Nick Roberts <nickrob@snap.net.nz>
Nick Roberts <nickrob@snap.net.nz>
parents: 67752
diff changeset
85 'action `(lambda (&rest ignore)
cc79e7966f97 2005-12-27 Nick Roberts <nickrob@snap.net.nz>
Nick Roberts <nickrob@snap.net.nz>
parents: 67752
diff changeset
86 (describe-text-category ',value))
102872
bd89d8afd5eb * descr-text.el (describe-property-list, describe-char): Add
Chong Yidong <cyd@stupidchicken.com>
parents: 101927
diff changeset
87 'follow-link t
67814
cc79e7966f97 2005-12-27 Nick Roberts <nickrob@snap.net.nz>
Nick Roberts <nickrob@snap.net.nz>
parents: 67752
diff changeset
88 'help-echo "mouse-2, RET: describe this category"))
58994
720c9b9bf376 (describe-property-list): Don't treat syntax-table
Juri Linkov <juri@jurta.org>
parents: 58416
diff changeset
89 ((memq key '(face font-lock-face mouse-face))
67865
f94acc1b8bc2 (describe-text-sexp): Use square brackets for
Juri Linkov <juri@jurta.org>
parents: 67855
diff changeset
90 (insert-text-button
f94acc1b8bc2 (describe-text-sexp): Use square brackets for
Juri Linkov <juri@jurta.org>
parents: 67855
diff changeset
91 (format "%S" value)
f94acc1b8bc2 (describe-text-sexp): Use square brackets for
Juri Linkov <juri@jurta.org>
parents: 67855
diff changeset
92 'type 'help-face 'help-args (list value)))
55754
da7a694d2097 (describe-property-list): Add [show] button for
Juri Linkov <juri@jurta.org>
parents: 55584
diff changeset
93 ((widgetp value)
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (describe-text-widget value))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 (t
58994
720c9b9bf376 (describe-property-list): Don't treat syntax-table
Juri Linkov <juri@jurta.org>
parents: 58416
diff changeset
96 (describe-text-sexp value))))
67752
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
97 (insert "\n")))
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 ;;; Describe-Text Commands.
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 (defun describe-text-category (category)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 "Describe a text property category."
67814
cc79e7966f97 2005-12-27 Nick Roberts <nickrob@snap.net.nz>
Nick Roberts <nickrob@snap.net.nz>
parents: 67752
diff changeset
103 (interactive "SCategory: ")
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 102872
diff changeset
104 (help-setup-xref (list #'describe-text-category category)
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 102872
diff changeset
105 (called-interactively-p 'interactive))
106224
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
106 (with-help-window (help-buffer)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
107 (with-current-buffer standard-output
67752
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
108 (insert "Category " (format "%S" category) ":\n\n")
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
109 (describe-property-list (symbol-plist category))
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 (goto-char (point-min)))))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 ;;;###autoload
106224
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
113 (defun describe-text-properties (pos &optional output-buffer buffer)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
114 "Describe widgets, buttons, overlays, and text properties at POS.
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
115 POS is taken to be in BUFFER or in current buffer if nil.
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
116 Interactively, describe them for the character after point.
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
117 If optional second argument OUTPUT-BUFFER is non-nil,
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
118 insert the output into that buffer, and don't initialize or clear it
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
119 otherwise."
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (interactive "d")
106224
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
121 (let ((src-buf (current-buffer)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
122 (if buffer (set-buffer buffer) (setq buffer (current-buffer)))
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
123 (if (>= pos (point-max))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
124 (error "No character follows specified position"))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
125 (if output-buffer
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
126 (describe-text-properties-1 pos output-buffer)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
127 (if (not (or (text-properties-at pos) (overlays-at pos)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
128 (message "This is plain text.")
106224
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
129 (with-temp-buffer
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
130 (setq output-buffer (current-buffer))
67752
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
131 (insert "Text content at position " (format "%d" pos) ":\n\n")
106224
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
132 (set-buffer buffer)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
133 (describe-text-properties-1 pos output-buffer)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
134 (set-buffer src-buf)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
135 (help-setup-xref (list 'describe-text-properties pos nil buffer)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
136 (called-interactively-p 'interactive))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
137 (with-help-window (help-buffer)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
138 (with-current-buffer standard-output
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
139 (buffer-swap-text output-buffer)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
140 (goto-char (point-min)))))))))
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
141
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
142 (defun describe-text-properties-1 (pos output-buffer)
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (let* ((properties (text-properties-at pos))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (overlays (overlays-at pos))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 (wid-field (get-char-property pos 'field))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (wid-button (get-char-property pos 'button))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 (wid-doc (get-char-property pos 'widget-doc))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 ;; If button.el is not loaded, we have no buttons in the text.
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 (button (and (fboundp 'button-at) (button-at pos)))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 (button-type (and button (button-type button)))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 (button-label (and button (button-label button)))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 (widget (or wid-field wid-button wid-doc)))
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
153 (with-current-buffer output-buffer
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
154 ;; Widgets
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
155 (when (widgetp widget)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
156 (newline)
67752
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
157 (insert (cond (wid-field "This is an editable text area")
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
158 (wid-button "This is an active area")
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
159 (wid-doc "This is documentation text")))
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
160 (insert " of a ")
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
161 (describe-text-widget widget)
67752
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
162 (insert ".\n\n"))
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
163 ;; Buttons
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
164 (when (and button (not (widgetp wid-button)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
165 (newline)
67865
f94acc1b8bc2 (describe-text-sexp): Use square brackets for
Juri Linkov <juri@jurta.org>
parents: 67855
diff changeset
166 (insert "Here is a `" (format "%S" button-type)
f94acc1b8bc2 (describe-text-sexp): Use square brackets for
Juri Linkov <juri@jurta.org>
parents: 67855
diff changeset
167 "' button labeled `" button-label "'.\n\n"))
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
168 ;; Overlays
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
169 (when overlays
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
170 (newline)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
171 (if (eq (length overlays) 1)
67752
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
172 (insert "There is an overlay here:\n")
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
173 (insert "There are " (format "%d" (length overlays))
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
174 " overlays here:\n"))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
175 (dolist (overlay overlays)
67752
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
176 (insert " From " (format "%d" (overlay-start overlay))
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
177 " to " (format "%d" (overlay-end overlay)) "\n")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
178 (describe-property-list (overlay-properties overlay)))
67752
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
179 (insert "\n"))
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
180 ;; Text properties
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
181 (when properties
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
182 (newline)
67752
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
183 (insert "There are text properties here:\n")
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
184 (describe-property-list properties)))))
51278
7192dc1bfcf4 (describe-char-unicode-data): New dummy definition.
Richard M. Stallman <rms@gnu.org>
parents: 51127
diff changeset
185
96754
79e210b5bd7b (describe-char-unidata-list): Initialize to the
Kenichi Handa <handa@m17n.org>
parents: 96416
diff changeset
186 (defcustom describe-char-unidata-list
99817
a5a1e57fb667 (describe-char-unidata-list): Move `old-name' to be immediately after `name'.
Juri Linkov <juri@jurta.org>
parents: 99151
diff changeset
187 '(name old-name general-category decomposition)
90087
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
188 "List of Unicode-based character property names shown by `describe-char'."
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
189 :group 'mule
90104
a01e7a9f1659 Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-14
Miles Bader <miles@gnu.org>
parents: 90103
diff changeset
190 :version "23.1"
93054
ca8b9e092766 (describe-char-unidata-list): Allow specifying just all properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91335
diff changeset
191 :type '(choice (const :tag "All properties" t)
ca8b9e092766 (describe-char-unidata-list): Allow specifying just all properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91335
diff changeset
192 (set
106320
4c6acb151625 (describe-char-unidata-list): Use lowercase name
Juri Linkov <juri@jurta.org>
parents: 106224
diff changeset
193 (const :tag "Unicode name" name)
99817
a5a1e57fb667 (describe-char-unidata-list): Move `old-name' to be immediately after `name'.
Juri Linkov <juri@jurta.org>
parents: 99151
diff changeset
194 (const :tag "Unicode old name" old-name)
93054
ca8b9e092766 (describe-char-unidata-list): Allow specifying just all properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91335
diff changeset
195 (const :tag "Unicode general category " general-category)
ca8b9e092766 (describe-char-unidata-list): Allow specifying just all properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91335
diff changeset
196 (const :tag "Unicode canonical combining class"
ca8b9e092766 (describe-char-unidata-list): Allow specifying just all properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91335
diff changeset
197 canonical-combining-class)
ca8b9e092766 (describe-char-unidata-list): Allow specifying just all properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91335
diff changeset
198 (const :tag "Unicode bidi class" bidi-class)
ca8b9e092766 (describe-char-unidata-list): Allow specifying just all properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91335
diff changeset
199 (const :tag "Unicode decomposition mapping" decomposition)
ca8b9e092766 (describe-char-unidata-list): Allow specifying just all properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91335
diff changeset
200 (const :tag "Unicode decimal digit value" decimal-digit-value)
ca8b9e092766 (describe-char-unidata-list): Allow specifying just all properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91335
diff changeset
201 (const :tag "Unicode digit value" digit-value)
ca8b9e092766 (describe-char-unidata-list): Allow specifying just all properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91335
diff changeset
202 (const :tag "Unicode numeric value" numeric-value)
ca8b9e092766 (describe-char-unidata-list): Allow specifying just all properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91335
diff changeset
203 (const :tag "Unicode mirrored" mirrored)
ca8b9e092766 (describe-char-unidata-list): Allow specifying just all properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91335
diff changeset
204 (const :tag "Unicode ISO 10646 comment" iso-10646-comment)
ca8b9e092766 (describe-char-unidata-list): Allow specifying just all properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91335
diff changeset
205 (const :tag "Unicode simple uppercase mapping" uppercase)
ca8b9e092766 (describe-char-unidata-list): Allow specifying just all properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91335
diff changeset
206 (const :tag "Unicode simple lowercase mapping" lowercase)
ca8b9e092766 (describe-char-unidata-list): Allow specifying just all properties.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91335
diff changeset
207 (const :tag "Unicode simple titlecase mapping" titlecase))))
90087
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
208
55584
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
209 (defcustom describe-char-unicodedata-file nil
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
210 "Location of Unicode data file.
74356
25c9571827a2 *** empty log message ***
Juanma Barranquero <lekktu@gmail.com>
parents: 68651
diff changeset
211 This is the UnicodeData.txt file from the Unicode Consortium, used for
59758
b8352a1f354a (describe-char-unicodedata-file): Docstring fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59752
diff changeset
212 diagnostics. If it is non-nil `describe-char' will print data
55584
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
213 looked up from it. This facility is mostly of use to people doing
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
214 multilingual development.
51127
d68739c97632 (unicodedata-file): New.
Dave Love <fx@gnu.org>
parents: 49588
diff changeset
215
74356
25c9571827a2 *** empty log message ***
Juanma Barranquero <lekktu@gmail.com>
parents: 68651
diff changeset
216 This is a fairly large file, not typically present on GNU systems.
25c9571827a2 *** empty log message ***
Juanma Barranquero <lekktu@gmail.com>
parents: 68651
diff changeset
217 At the time of writing it is at the URL
67752
dd459879f1e7 Add FSF as maintainer.
Nick Roberts <nickrob@snap.net.nz>
parents: 67559
diff changeset
218 `http://www.unicode.org/Public/UNIDATA/UnicodeData.txt'."
55584
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
219 :group 'mule
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59758
diff changeset
220 :version "22.1"
55584
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
221 :type '(choice (const :tag "None" nil)
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
222 file))
51278
7192dc1bfcf4 (describe-char-unicode-data): New dummy definition.
Richard M. Stallman <rms@gnu.org>
parents: 51127
diff changeset
223
55584
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
224 (defun describe-char-unicode-data (char)
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
225 "Return a list of Unicode data for unicode CHAR.
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
226 Each element is a list of a property description and the property value.
90087
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
227 The list is null if CHAR isn't found in `describe-char-unicodedata-file'.
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
228 This function is semi-obsolete. Use `get-char-code-property'."
55584
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
229 (when describe-char-unicodedata-file
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
230 (unless (file-exists-p describe-char-unicodedata-file)
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
231 (error "`unicodedata-file' %s not found" describe-char-unicodedata-file))
74403
04f1edde004d (describe-char-unicode-data): Use a hidden buffer for Unicode data file pointed
Juanma Barranquero <lekktu@gmail.com>
parents: 74356
diff changeset
232 (with-current-buffer (get-buffer-create " *Unicode Data*")
04f1edde004d (describe-char-unicode-data): Use a hidden buffer for Unicode data file pointed
Juanma Barranquero <lekktu@gmail.com>
parents: 74356
diff changeset
233 (when (zerop (buffer-size))
04f1edde004d (describe-char-unicode-data): Use a hidden buffer for Unicode data file pointed
Juanma Barranquero <lekktu@gmail.com>
parents: 74356
diff changeset
234 ;; Don't use -literally in case of DOS line endings.
04f1edde004d (describe-char-unicode-data): Use a hidden buffer for Unicode data file pointed
Juanma Barranquero <lekktu@gmail.com>
parents: 74356
diff changeset
235 (insert-file-contents describe-char-unicodedata-file))
55584
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
236 (goto-char (point-min))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
237 (let ((hex (format "%04X" char))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
238 found first last)
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
239 (if (re-search-forward (concat "^" hex) nil t)
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
240 (setq found t)
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
241 ;; It's not listed explicitly. Look for ranges, e.g. CJK
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
242 ;; ideographs, and check whether it's in one of them.
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
243 (while (and (re-search-forward "^\\([^;]+\\);[^;]+First>;" nil t)
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
244 (>= char (setq first
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
245 (string-to-number (match-string 1) 16)))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
246 (progn
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
247 (forward-line 1)
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
248 (looking-at "^\\([^;]+\\);[^;]+Last>;")
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
249 (> char
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
250 (setq last
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
251 (string-to-number (match-string 1) 16))))))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
252 (if (and (>= char first)
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
253 (<= char last))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
254 (setq found t)))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
255 (if found
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
256 (let ((fields (mapcar (lambda (elt)
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
257 (if (> (length elt) 0)
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
258 elt))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
259 (cdr (split-string
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
260 (buffer-substring
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
261 (line-beginning-position)
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
262 (line-end-position))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
263 ";")))))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
264 ;; The length depends on whether the last field was empty.
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
265 (unless (or (= 13 (length fields))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
266 (= 14 (length fields)))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
267 (error "Invalid contents in %s" describe-char-unicodedata-file))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
268 ;; The field names and values lists are slightly
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
269 ;; modified from Mule-UCS unidata.el.
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
270 (list
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
271 (list "Name" (let ((name (nth 0 fields)))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
272 ;; Check for <..., First>, <..., Last>
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
273 (if (string-match "\\`\\(<[^,]+\\)," name)
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
274 (concat (match-string 1 name) ">")
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
275 name)))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
276 (list "Category"
90087
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
277 (let ((val (nth 1 fields)))
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
278 (or (char-code-property-description
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
279 'general-category (intern val))
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
280 val)))
55584
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
281 (list "Combining class"
90087
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
282 (let ((val (nth 1 fields)))
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
283 (or (char-code-property-description
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
284 'canonical-combining-class (intern val))
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
285 val)))
55584
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
286 (list "Bidi category"
90087
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
287 (let ((val (nth 1 fields)))
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
288 (or (char-code-property-description
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
289 'bidi-class (intern val))
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
290 val)))
55584
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
291 (list
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
292 "Decomposition"
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
293 (if (nth 4 fields)
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
294 (let* ((parts (split-string (nth 4 fields)))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
295 (info (car parts)))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
296 (if (string-match "\\`<\\(.+\\)>\\'" info)
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
297 (setq info (match-string 1 info))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
298 (setq info nil))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
299 (if info (setq parts (cdr parts)))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
300 (setq parts (mapconcat
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
301 (lambda (arg)
90087
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
302 (string (string-to-number arg 16)))
55584
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
303 parts " "))
109244
35c5071647d4 Close bug#6422.
Glenn Morris <rgm@gnu.org>
parents: 108933
diff changeset
304 (concat info (if info " ") parts))))
55584
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
305 (list "Decimal digit value"
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
306 (nth 5 fields))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
307 (list "Digit value"
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
308 (nth 6 fields))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
309 (list "Numeric value"
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
310 (nth 7 fields))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
311 (list "Mirrored"
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
312 (if (equal "Y" (nth 8 fields))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
313 "yes"))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
314 (list "Old name" (nth 9 fields))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
315 (list "ISO 10646 comment" (nth 10 fields))
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
316 (list "Uppercase" (and (nth 11 fields)
90087
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
317 (string (string-to-number
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
318 (nth 11 fields) 16))))
55584
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
319 (list "Lowercase" (and (nth 12 fields)
90087
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
320 (string (string-to-number
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
321 (nth 12 fields) 16))))
55584
bdbbd721cc67 (describe-char-unicode-data, describe-char-unicodedata-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55543
diff changeset
322 (list "Titlecase" (and (nth 13 fields)
90087
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
323 (string (string-to-number
230281e520b3 (describe-char-unidata-list): New variable.
Kenichi Handa <handa@m17n.org>
parents: 90085
diff changeset
324 (nth 13 fields) 16)))))))))))
52655
8d4e6d1d7201 (describe-char-display): New function.
Kenichi Handa <handa@m17n.org>
parents: 52401
diff changeset
325
95841
b4e36ff621b3 Add some compiler declarations, for builds without X.
Glenn Morris <rgm@gnu.org>
parents: 95455
diff changeset
326 ;; Not defined on builds without X, but behind display-graphic-p.
b4e36ff621b3 Add some compiler declarations, for builds without X.
Glenn Morris <rgm@gnu.org>
parents: 95455
diff changeset
327 (declare-function internal-char-font "fontset.c" (position &optional ch))
b4e36ff621b3 Add some compiler declarations, for builds without X.
Glenn Morris <rgm@gnu.org>
parents: 95455
diff changeset
328
52655
8d4e6d1d7201 (describe-char-display): New function.
Kenichi Handa <handa@m17n.org>
parents: 52401
diff changeset
329 ;; Return information about how CHAR is displayed at the buffer
8d4e6d1d7201 (describe-char-display): New function.
Kenichi Handa <handa@m17n.org>
parents: 52401
diff changeset
330 ;; position POS. If the selected frame is on a graphic display,
96416
959951d0e3b9 (describe-char-display): Always return a string.
Kenichi Handa <handa@m17n.org>
parents: 95841
diff changeset
331 ;; return a string "FONT-DRIVER:FONT-NAME (GLYPH-CODE)" where:
959951d0e3b9 (describe-char-display): Always return a string.
Kenichi Handa <handa@m17n.org>
parents: 95841
diff changeset
332 ;; FONT-DRIVER is the font-driver name,
959951d0e3b9 (describe-char-display): Always return a string.
Kenichi Handa <handa@m17n.org>
parents: 95841
diff changeset
333 ;; FONT-NAME is the font name,
959951d0e3b9 (describe-char-display): Always return a string.
Kenichi Handa <handa@m17n.org>
parents: 95841
diff changeset
334 ;; GLYPH-CODE is a hexadigit string representing the glyph-ID.
959951d0e3b9 (describe-char-display): Always return a string.
Kenichi Handa <handa@m17n.org>
parents: 95841
diff changeset
335 ;; Otherwise, return a string describing the terminal codes for the
959951d0e3b9 (describe-char-display): Always return a string.
Kenichi Handa <handa@m17n.org>
parents: 95841
diff changeset
336 ;; character.
52655
8d4e6d1d7201 (describe-char-display): New function.
Kenichi Handa <handa@m17n.org>
parents: 52401
diff changeset
337 (defun describe-char-display (pos char)
8d4e6d1d7201 (describe-char-display): New function.
Kenichi Handa <handa@m17n.org>
parents: 52401
diff changeset
338 (if (display-graphic-p (selected-frame))
91328
f64f6ef4cdfe (describe-char-display): Convert a GLYPH-CODE to a
Kenichi Handa <handa@m17n.org>
parents: 91327
diff changeset
339 (let ((char-font-info (internal-char-font pos char)))
91335
07ce8496076f (describe-char-display): Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 91328
diff changeset
340 (if char-font-info
96416
959951d0e3b9 (describe-char-display): Always return a string.
Kenichi Handa <handa@m17n.org>
parents: 95841
diff changeset
341 (let ((type (font-get (car char-font-info) :type))
97005
8e17e43e57e9 * descr-text.el (describe-char): Don't overwrite local variable char
Juanma Barranquero <lekktu@gmail.com>
parents: 96754
diff changeset
342 (name (font-xlfd-name (car char-font-info)))
96416
959951d0e3b9 (describe-char-display): Always return a string.
Kenichi Handa <handa@m17n.org>
parents: 95841
diff changeset
343 (code (cdr char-font-info)))
959951d0e3b9 (describe-char-display): Always return a string.
Kenichi Handa <handa@m17n.org>
parents: 95841
diff changeset
344 (if (integerp code)
959951d0e3b9 (describe-char-display): Always return a string.
Kenichi Handa <handa@m17n.org>
parents: 95841
diff changeset
345 (format "%s:%s (#x%02X)" type name code)
959951d0e3b9 (describe-char-display): Always return a string.
Kenichi Handa <handa@m17n.org>
parents: 95841
diff changeset
346 (format "%s:%s (#x%04X%04X)"
959951d0e3b9 (describe-char-display): Always return a string.
Kenichi Handa <handa@m17n.org>
parents: 95841
diff changeset
347 type name (car code) (cdr code))))))
97196
15d4d10ad710 (describe-char-display): Call encode-coding-char
Kenichi Handa <handa@m17n.org>
parents: 97005
diff changeset
348 (let* ((charset (get-text-property pos 'charset))
101927
c63836b5986a (describe-char-display): On terminal, if terminal
Kenichi Handa <handa@m17n.org>
parents: 101781
diff changeset
349 (coding (or (terminal-coding-system) 'us-ascii))
97196
15d4d10ad710 (describe-char-display): Call encode-coding-char
Kenichi Handa <handa@m17n.org>
parents: 97005
diff changeset
350 (encoded (encode-coding-char char coding charset)))
52655
8d4e6d1d7201 (describe-char-display): New function.
Kenichi Handa <handa@m17n.org>
parents: 52401
diff changeset
351 (if encoded
97259
067d03b2ec89 * descr-text.el (describe-char-display): Fix last change:
Juanma Barranquero <lekktu@gmail.com>
parents: 97196
diff changeset
352 (encoded-string-description encoded coding)))))
52655
8d4e6d1d7201 (describe-char-display): New function.
Kenichi Handa <handa@m17n.org>
parents: 52401
diff changeset
353
51278
7192dc1bfcf4 (describe-char-unicode-data): New dummy definition.
Richard M. Stallman <rms@gnu.org>
parents: 51127
diff changeset
354
96416
959951d0e3b9 (describe-char-display): Always return a string.
Kenichi Handa <handa@m17n.org>
parents: 95841
diff changeset
355 ;; Return a string of CH with composition for padding on both sides.
959951d0e3b9 (describe-char-display): Always return a string.
Kenichi Handa <handa@m17n.org>
parents: 95841
diff changeset
356 ;; It is displayed without overlapping with the left/right columns.
959951d0e3b9 (describe-char-display): Always return a string.
Kenichi Handa <handa@m17n.org>
parents: 95841
diff changeset
357 (defsubst describe-char-padded-string (ch)
106106
a3ea15b56766 (describe-char-padded-string): Compose with TAB
Kenichi Handa <handa@m17n.org>
parents: 105850
diff changeset
358 (if (internal-char-font nil ch)
a3ea15b56766 (describe-char-padded-string): Compose with TAB
Kenichi Handa <handa@m17n.org>
parents: 105850
diff changeset
359 (compose-string (string ch) 0 1 (format "\t%c\t" ch))
a3ea15b56766 (describe-char-padded-string): Compose with TAB
Kenichi Handa <handa@m17n.org>
parents: 105850
diff changeset
360 (string ch)))
96416
959951d0e3b9 (describe-char-display): Always return a string.
Kenichi Handa <handa@m17n.org>
parents: 95841
diff changeset
361
101290
017ab5339c4c * descr-text.el (describe-char-categories): New defsubst.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
362 ;; Return a nicely formated list of categories; extended category
017ab5339c4c * descr-text.el (describe-char-categories): New defsubst.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
363 ;; description is added to the category name as a tooltip
017ab5339c4c * descr-text.el (describe-char-categories): New defsubst.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
364 (defsubst describe-char-categories (category-set)
017ab5339c4c * descr-text.el (describe-char-categories): New defsubst.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
365 (let ((mnemonics (category-set-mnemonics category-set)))
017ab5339c4c * descr-text.el (describe-char-categories): New defsubst.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
366 (unless (eq mnemonics "")
017ab5339c4c * descr-text.el (describe-char-categories): New defsubst.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
367 (list (mapconcat
017ab5339c4c * descr-text.el (describe-char-categories): New defsubst.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
368 #'(lambda (x)
017ab5339c4c * descr-text.el (describe-char-categories): New defsubst.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
369 (let* ((c (category-docstring x))
017ab5339c4c * descr-text.el (describe-char-categories): New defsubst.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
370 (doc (if (string-match "\\`\\(.*?\\)\n\\(.*\\)\\'" c)
017ab5339c4c * descr-text.el (describe-char-categories): New defsubst.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
371 (propertize (match-string 1 c)
017ab5339c4c * descr-text.el (describe-char-categories): New defsubst.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
372 'help-echo (match-string 2 c))
017ab5339c4c * descr-text.el (describe-char-categories): New defsubst.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
373 c)))
017ab5339c4c * descr-text.el (describe-char-categories): New defsubst.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
374 (format "%c:%s" x doc)))
017ab5339c4c * descr-text.el (describe-char-categories): New defsubst.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
375 mnemonics ", ")))))
017ab5339c4c * descr-text.el (describe-char-categories): New defsubst.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
376
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
377 ;;;###autoload
106224
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
378 (defun describe-char (pos &optional buffer)
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
379 "Describe the character after POS (interactively, the character after point).
106224
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
380 Is POS is taken to be in buffer BUFFER or current buffer if nil.
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
381 The information includes character code, charset and code points in it,
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
382 syntax, category, how the character is encoded in a file,
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
383 character composition information (if relevant),
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
384 as well as widgets, buttons, overlays, and text properties."
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
385 (interactive "d")
106224
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
386 (unless (buffer-live-p buffer) (setq buffer (current-buffer)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
387 (let ((src-buf (current-buffer)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
388 (set-buffer buffer)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
389 (if (>= pos (point-max))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
390 (error "No character follows specified position"))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
391 (let* ((char (char-after pos))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
392 (eight-bit-p (and (not enable-multibyte-characters) (>= char 128)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
393 (charset (if eight-bit-p 'eight-bit
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
394 (or (get-text-property pos 'charset)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
395 (char-charset char))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
396 (composition (find-composition pos nil nil t))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
397 (component-chars nil)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
398 (display-table (or (window-display-table)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
399 buffer-display-table
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
400 standard-display-table))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
401 (disp-vector (and display-table (aref display-table char)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
402 (multibyte-p enable-multibyte-characters)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
403 (overlays (mapcar #'(lambda (o) (overlay-properties o))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
404 (overlays-at pos)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
405 (char-description (if (not multibyte-p)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
406 (single-key-description char)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
407 (if (< char 128)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
408 (single-key-description char)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
409 (string-to-multibyte
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
410 (char-to-string char)))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
411 (text-props-desc
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
412 (let ((tmp-buf (generate-new-buffer " *text-props*")))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
413 (unwind-protect
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
414 (progn
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
415 (describe-text-properties pos tmp-buf)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
416 (with-current-buffer tmp-buf (buffer-string)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
417 (kill-buffer tmp-buf))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
418 item-list max-width code)
51127
d68739c97632 (unicodedata-file): New.
Dave Love <fx@gnu.org>
parents: 49588
diff changeset
419
106224
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
420 (if multibyte-p
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
421 (or (setq code (encode-char char charset))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
422 (setq charset (char-charset char)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
423 code (encode-char char charset)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
424 (setq code char))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
425 (when composition
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
426 ;; When the composition is trivial (i.e. composed only with the
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
427 ;; current character itself without any alternate characters),
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
428 ;; we don't show the composition information. Otherwise, store
108933
b465aa3255ed Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
429 ;; two descriptive strings in the first two elements of
106224
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
430 ;; COMPOSITION.
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
431 (or (catch 'tag
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
432 (let ((from (car composition))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
433 (to (nth 1 composition))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
434 (components (nth 2 composition))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
435 ch)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
436 (if (and (vectorp components) (vectorp (aref components 0)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
437 (let ((idx (- pos from))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
438 (nglyphs (lgstring-glyph-len components))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
439 (i 0) j glyph glyph-from)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
440 ;; COMPONENTS is a gstring. Find a grapheme
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
441 ;; cluster containing the current character.
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
442 (while (and (< i nglyphs)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
443 (setq glyph (lgstring-glyph components i))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
444 (< (lglyph-to glyph) idx))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
445 (setq i (1+ i)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
446 (if (or (not glyph) (= i nglyphs))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
447 ;; The composition is broken.
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
448 (throw 'tag nil))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
449 (setq glyph-from (lglyph-from glyph)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
450 to (+ from (lglyph-to glyph) 1)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
451 from (+ from glyph-from)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
452 j i)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
453 (while (and (< j nglyphs)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
454 (setq glyph (lgstring-glyph components j))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
455 (= (lglyph-from glyph) glyph-from))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
456 (setq j (1+ j)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
457 (if (and (= to (1+ from))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
458 (= i (1- j))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
459 (setq glyph (lgstring-glyph components i))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
460 (= char (lglyph-char glyph)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
461 ;; The composition is trivial.
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
462 (throw 'tag nil))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
463 (nconc composition (list i (1- j))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
464 (dotimes (i (length components))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
465 (if (integerp (setq ch (aref components i)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
466 (push (cons ch (describe-char-display pos ch))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
467 component-chars)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
468 (setq component-chars (nreverse component-chars)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
469 (if (< from pos)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
470 (if (< (1+ pos) to)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
471 (setcar composition
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
472 (concat
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
473 " with the surrounding characters \""
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
474 (mapconcat 'describe-char-padded-string
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
475 (buffer-substring from pos) "")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
476 "\" and \""
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
477 (mapconcat 'describe-char-padded-string
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
478 (buffer-substring (1+ pos) to) "")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
479 "\""))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
480 (setcar composition
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
481 (concat
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
482 " with the preceding character(s) \""
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
483 (mapconcat 'describe-char-padded-string
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
484 (buffer-substring from pos) "")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
485 "\"")))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
486 (if (< (1+ pos) to)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
487 (setcar composition
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
488 (concat
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
489 " with the following character(s) \""
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
490 (mapconcat 'describe-char-padded-string
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
491 (buffer-substring (1+ pos) to) "")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
492 "\""))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
493 (setcar composition nil)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
494 (setcar (cdr composition)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
495 (format "composed to form \"%s\" (see below)"
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
496 (buffer-substring from to)))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
497 (setq composition nil)))
101927
c63836b5986a (describe-char-display): On terminal, if terminal
Kenichi Handa <handa@m17n.org>
parents: 101781
diff changeset
498
106224
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
499 (setq item-list
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
500 `(("character"
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
501 ,(format "%s (%d, #o%o, #x%x)"
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
502 (apply 'propertize char-description
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
503 (text-properties-at pos))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
504 char char char))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
505 ("preferred charset"
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
506 ,`(insert-text-button
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
507 ,(symbol-name charset)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
508 'type 'help-character-set 'help-args '(,charset))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
509 ,(format "(%s)" (charset-description charset)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
510 ("code point"
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
511 ,(let ((str (if (integerp code)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
512 (format (if (< code 256) "0x%02X" "0x%04X")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
513 code)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
514 (format "0x%04X%04X" (car code) (cdr code)))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
515 (if (<= (charset-dimension charset) 2)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
516 `(insert-text-button
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
517 ,str
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
518 'action (lambda (&rest ignore)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
519 (list-charset-chars ',charset)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
520 (with-selected-window
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
521 (get-buffer-window "*Character List*" 0)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
522 (goto-char (point-min))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
523 (forward-line 2) ;Skip the header.
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
524 (let ((case-fold-search nil))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
525 (if (search-forward
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
526 ,(char-to-string char) nil t)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
527 (goto-char (match-beginning 0))))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
528 'follow-link t
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
529 'help-echo
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
530 "mouse-2, RET: show this character in its character set")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
531 str)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
532 ("syntax"
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
533 ,(let ((syntax (syntax-after pos)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
534 (with-temp-buffer
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
535 (internal-describe-syntax-value syntax)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
536 (buffer-string))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
537 ("category"
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
538 ,@(if (not eight-bit-p)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
539 (let ((category-set (char-category-set char)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
540 (if category-set
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
541 (describe-char-categories category-set)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
542 '("-- none --")))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
543 ("to input"
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
544 ,@(if (not eight-bit-p)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
545 (let ((key-list (and (eq input-method-function
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
546 'quail-input-method)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
547 (quail-find-key char))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
548 (if (consp key-list)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
549 (list "type"
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
550 (concat "\""
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
551 (mapconcat 'identity
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
552 key-list "\" or \"")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
553 "\"")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
554 "with"
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
555 `(insert-text-button
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
556 ,current-input-method
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
557 'type 'help-input-method
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
558 'help-args '(,current-input-method)))))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
559 ("buffer code"
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
560 ,(if multibyte-p
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
561 (encoded-string-description
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
562 (string-as-unibyte (char-to-string char)) nil)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
563 (format "#x%02X" char)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
564 ("file code"
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
565 ,@(if multibyte-p
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
566 (let* ((coding buffer-file-coding-system)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
567 (encoded (encode-coding-char char coding charset)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
568 (if encoded
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
569 (list (encoded-string-description encoded coding)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
570 (format "(encoded by coding system %S)"
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
571 coding))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
572 (list "not encodable by coding system"
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
573 (symbol-name coding))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
574 (list (format "#x%02X" char))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
575 ("display"
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
576 ,(cond
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
577 (disp-vector
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
578 (setq disp-vector (copy-sequence disp-vector))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
579 (dotimes (i (length disp-vector))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
580 (aset disp-vector i
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
581 (cons (aref disp-vector i)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
582 (describe-char-display
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
583 pos (glyph-char (aref disp-vector i))))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
584 (format "by display table entry [%s] (see below)"
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
585 (mapconcat
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
586 #'(lambda (x)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
587 (format "?%c" (glyph-char (car x))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
588 disp-vector " ")))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
589 (composition
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
590 (cadr composition))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
591 (t
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
592 (let ((display (describe-char-display pos char)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
593 (if (display-graphic-p (selected-frame))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
594 (if display
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
595 (concat "by this font (glyph code)\n " display)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
596 "no font available")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
597 (if display
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
598 (format "terminal code %s" display)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
599 "not encodable for terminal"))))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
600 ,@(let ((face
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
601 (if (not (or disp-vector composition))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
602 (cond
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
603 ((and show-trailing-whitespace
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
604 (save-excursion (goto-char pos)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
605 (looking-at-p "[ \t]+$")))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
606 'trailing-whitespace)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
607 ((and nobreak-char-display char (eq char '#xa0))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
608 'nobreak-space)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
609 ((and nobreak-char-display char (eq char '#xad))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
610 'escape-glyph)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
611 ((and (< char 32) (not (memq char '(9 10))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
612 'escape-glyph)))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
613 (if face (list (list "hardcoded face"
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
614 `(insert-text-button
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
615 ,(symbol-name face)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
616 'type 'help-face
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
617 'help-args '(,face))))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
618 ,@(if (not eight-bit-p)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
619 (let ((unicodedata (describe-char-unicode-data char)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
620 (if unicodedata
109023
8d29522e59d4 * lisp/descr-text.el (describe-char): Avoid trailing whitespace. (Bug#6423)
Glenn Morris <rgm@gnu.org>
parents: 108933
diff changeset
621 (cons (list "Unicode data" "") unicodedata))))))
106224
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
622 (setq max-width (apply 'max (mapcar (lambda (x)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
623 (if (cadr x) (length (car x)) 0))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
624 item-list)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
625 (set-buffer src-buf)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
626 (help-setup-xref (list 'describe-char pos buffer)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
627 (called-interactively-p 'interactive))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
628 (with-help-window (help-buffer)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
629 (with-current-buffer standard-output
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
630 (set-buffer-multibyte multibyte-p)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
631 (let ((formatter (format "%%%ds:" max-width)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
632 (dolist (elt item-list)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
633 (when (cadr elt)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
634 (insert (format formatter (car elt)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
635 (dolist (clm (cdr elt))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
636 (if (eq (car-safe clm) 'insert-text-button)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
637 (progn (insert " ") (eval clm))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
638 (when (>= (+ (current-column)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
639 (or (string-match-p "\n" clm)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
640 (string-width clm))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
641 1)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
642 (window-width))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
643 (insert "\n")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
644 (indent-to (1+ max-width)))
109023
8d29522e59d4 * lisp/descr-text.el (describe-char): Avoid trailing whitespace. (Bug#6423)
Glenn Morris <rgm@gnu.org>
parents: 108933
diff changeset
645 (unless (zerop (length clm))
8d29522e59d4 * lisp/descr-text.el (describe-char): Avoid trailing whitespace. (Bug#6423)
Glenn Morris <rgm@gnu.org>
parents: 108933
diff changeset
646 (insert " " clm))))
106224
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
647 (insert "\n"))))
52655
8d4e6d1d7201 (describe-char-display): New function.
Kenichi Handa <handa@m17n.org>
parents: 52401
diff changeset
648
106224
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
649 (when overlays
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
650 (save-excursion
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
651 (goto-char (point-min))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
652 (re-search-forward "character:[ \t\n]+")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
653 (let ((end (+ (point) (length char-description))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
654 (mapc #'(lambda (props)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
655 (let ((o (make-overlay (point) end)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
656 (while props
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
657 (overlay-put o (car props) (nth 1 props))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
658 (setq props (cddr props)))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
659 overlays))))
55491
79abf8a72f5a (describe-char): Fix previous change. Don't make
Kenichi Handa <handa@m17n.org>
parents: 55305
diff changeset
660
106224
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
661 (when disp-vector
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
662 (insert
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
663 "\nThe display table entry is displayed by ")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
664 (if (display-graphic-p (selected-frame))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
665 (progn
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
666 (insert "these fonts (glyph codes):\n")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
667 (dotimes (i (length disp-vector))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
668 (insert (glyph-char (car (aref disp-vector i))) ?:
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
669 (propertize " " 'display '(space :align-to 5))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
670 (or (cdr (aref disp-vector i)) "-- no font --")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
671 "\n")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
672 (let ((face (glyph-face (car (aref disp-vector i)))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
673 (when face
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
674 (insert (propertize " " 'display '(space :align-to 5))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
675 "face: ")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
676 (insert (concat "`" (symbol-name face) "'"))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
677 (insert "\n")))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
678 (insert "these terminal codes:\n")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
679 (dotimes (i (length disp-vector))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
680 (insert (car (aref disp-vector i))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
681 (propertize " " 'display '(space :align-to 5))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
682 (or (cdr (aref disp-vector i)) "-- not encodable --")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
683 "\n"))))
52655
8d4e6d1d7201 (describe-char-display): New function.
Kenichi Handa <handa@m17n.org>
parents: 52401
diff changeset
684
106224
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
685 (when composition
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
686 (insert "\nComposed")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
687 (if (car composition)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
688 (insert (car composition)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
689 (if (and (vectorp (nth 2 composition))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
690 (vectorp (aref (nth 2 composition) 0)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
691 (let* ((gstring (nth 2 composition))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
692 (font (lgstring-font gstring))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
693 (from (nth 3 composition))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
694 (to (nth 4 composition))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
695 glyph)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
696 (if (fontp font)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
697 (progn
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
698 (insert " using this font:\n "
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
699 (symbol-name (font-get font :type))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
700 ?:
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
701 (aref (query-font font) 0)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
702 "\nby these glyphs:\n")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
703 (while (and (<= from to)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
704 (setq glyph (lgstring-glyph gstring from)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
705 (insert (format " %S\n" glyph))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
706 (setq from (1+ from))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
707 (insert " by these characters:\n")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
708 (while (and (<= from to)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
709 (setq glyph (lgstring-glyph gstring from)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
710 (insert (format " %c (#x%d)\n"
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
711 (lglyph-char glyph) (lglyph-char glyph)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
712 (setq from (1+ from)))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
713 (insert " by the rule:\n\t(")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
714 (let ((first t))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
715 (mapc (lambda (x)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
716 (if first (setq first nil)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
717 (insert " "))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
718 (if (consp x) (insert (format "%S" x))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
719 (if (= x ?\t) (insert (single-key-description x))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
720 (insert ??)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
721 (insert (describe-char-padded-string x)))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
722 (nth 2 composition)))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
723 (insert ")\nThe component character(s) are displayed by ")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
724 (if (display-graphic-p (selected-frame))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
725 (progn
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
726 (insert "these fonts (glyph codes):")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
727 (dolist (elt component-chars)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
728 (if (/= (car elt) ?\t)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
729 (insert "\n "
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
730 (describe-char-padded-string (car elt))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
731 ?:
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
732 (propertize " "
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
733 'display '(space :align-to 5))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
734 (or (cdr elt) "-- no font --")))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
735 (insert "these terminal codes:")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
736 (dolist (elt component-chars)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
737 (insert "\n " (car elt) ":"
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
738 (propertize " " 'display '(space :align-to 4))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
739 (or (cdr elt) "-- not encodable --"))))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
740 (insert "\nSee the variable `reference-point-alist' for "
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
741 "the meaning of the rule.\n")))
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
742
106224
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
743 (unless eight-bit-p
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
744 (insert (if (not describe-char-unidata-list)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
745 "\nCharacter code properties are not shown: "
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
746 "\nCharacter code properties: "))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
747 (insert-text-button
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
748 "customize what to show"
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
749 'action (lambda (&rest ignore)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
750 (customize-variable
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
751 'describe-char-unidata-list))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
752 'follow-link t)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
753 (insert "\n")
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
754 (dolist (elt (if (eq describe-char-unidata-list t)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
755 (nreverse (mapcar 'car char-code-property-alist))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
756 describe-char-unidata-list))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
757 (let ((val (get-char-code-property char elt))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
758 description)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
759 (when val
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
760 (setq description (char-code-property-description elt val))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
761 (insert (if description
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
762 (format " %s: %s (%s)\n" elt val description)
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
763 (format " %s: %s\n" elt val)))))))
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
764
106224
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
765 (if text-props-desc (insert text-props-desc))
647b4d392557 Handle the [back] button properly (bug#4979).
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106106
diff changeset
766 (toggle-read-only 1))))))
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767
94147
587f5f26f25d (describe-char-after): Use `define-obsolete-function-alias'.
Juanma Barranquero <lekktu@gmail.com>
parents: 93058
diff changeset
768 (define-obsolete-function-alias 'describe-char-after 'describe-char "22.1")
51127
d68739c97632 (unicodedata-file): New.
Dave Love <fx@gnu.org>
parents: 49588
diff changeset
769
45700
a54155344566 (toplevel): Provide `descr-text'.
Colin Walters <walters@gnu.org>
parents: 45697
diff changeset
770 (provide 'descr-text)
a54155344566 (toplevel): Provide `descr-text'.
Colin Walters <walters@gnu.org>
parents: 45697
diff changeset
771
58416
28906724d6e3 (syntax-after): Undo last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58150
diff changeset
772 ;; arch-tag: fc55a498-f3e9-4312-b5bd-98cc02480af1
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773 ;;; descr-text.el ends here