annotate lisp/descr-text.el @ 47539:663c306c80c6

(calc-mode): Add font-lock-defontify to change-major-mode-hook.
author Colin Walters <walters@gnu.org>
date Wed, 18 Sep 2002 16:47:48 +0000
parents 0c38024f4c40
children 7d00d911e8b9
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
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3 ;; Copyright (c) 1994, 1995, 1996, 2001, 2002 Free Software Foundation, Inc.
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Boris Goldowsky <boris@gnu.org>
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Keywords: faces
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
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 ;; GNU Emacs is free software; you can redistribute it and/or modify
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; any later version.
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; 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
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
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
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 (defun describe-text-done ()
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 "Delete the current window or bury the current buffer."
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 (interactive)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 (if (> (count-windows) 1)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 (delete-window)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 (bury-buffer)))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 (defvar describe-text-mode-map
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 (let ((map (make-sparse-keymap)))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 (set-keymap-parent map widget-keymap)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 map)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 "Keymap for `describe-text-mode'.")
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 (defcustom describe-text-mode-hook nil
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 "List of hook functions ran by `describe-text-mode'."
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 :type 'hook)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 (defun describe-text-mode ()
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
49 "Major mode for buffers created by `describe-char'.
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 \\{describe-text-mode-map}
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 Entry to this mode calls the value of `describe-text-mode-hook'
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 if that value is non-nil."
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 (kill-all-local-variables)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 (setq major-mode 'describe-text-mode
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 mode-name "Describe-Text")
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 (use-local-map describe-text-mode-map)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 (widget-setup)
47379
0c38024f4c40 (describe-text-mode): Add font-lock-defontify to change-major-mode-hook.
Richard M. Stallman <rms@gnu.org>
parents: 45996
diff changeset
59 (add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 (run-hooks 'describe-text-mode-hook))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;;; Describe-Text Utilities.
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 (defun describe-text-widget (widget)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 "Insert text to describe WIDGET in the current buffer."
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 (widget-create 'link
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 :notify `(lambda (&rest ignore)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 (widget-browse ',widget))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 (format "%S" (if (symbolp widget)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 widget
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 (car widget))))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 (widget-insert " ")
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 (widget-create 'info-link :tag "widget" "(widget)Top"))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 (defun describe-text-sexp (sexp)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 "Insert a short description of SEXP in the current buffer."
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (let ((pp (condition-case signal
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (pp-to-string sexp)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 (error (prin1-to-string signal)))))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 (when (string-match "\n\\'" pp)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (setq pp (substring pp 0 (1- (length pp)))))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (if (cond ((string-match "\n" pp)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 nil)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 ((> (length pp) (- (window-width) (current-column)))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 nil)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 (t t))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 (widget-insert pp)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (widget-create 'push-button
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 :tag "show"
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 :action (lambda (widget &optional event)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (with-output-to-temp-buffer
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 "*Pp Eval Output*"
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (princ (widget-get widget :value))))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 pp))))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
96 (defun describe-property-list (properties)
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 "Insert a description of PROPERTIES in the current buffer.
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 PROPERTIES should be a list of overlay or text properties.
45996
d57daf0a986a (describe-property-list): Make sure there's
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45868
diff changeset
99 The `category' property is made into a widget button that call
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 `describe-text-category' 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
101 ;; Sort the properties by the size of their value.
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
102 (dolist (elt (sort (let ((ret nil)
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
103 (key nil)
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
104 (val nil)
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
105 (len nil))
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
106 (while properties
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
107 (setq key (pop properties)
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
108 val (pop properties)
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
109 len 0)
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
110 (unless (or (eq key 'category)
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
111 (widgetp val))
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
112 (setq val (pp-to-string val)
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
113 len (length val)))
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
114 (push (list key val len) ret))
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
115 ret)
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
116 (lambda (a b)
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
117 (< (nth 2 a)
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
118 (nth 2 b)))))
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
119 (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
120 (value (nth 1 elt)))
45996
d57daf0a986a (describe-property-list): Make sure there's
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45868
diff changeset
121 (widget-insert (propertize (format " %-20s " key)
45697
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
122 'font-lock-face 'italic))
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (cond ((eq key 'category)
45996
d57daf0a986a (describe-property-list): Make sure there's
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45868
diff changeset
124 (widget-create 'link
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 :notify `(lambda (&rest ignore)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (describe-text-category ',value))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (format "%S" value)))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 ((widgetp value)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 (describe-text-widget value))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (t
45697
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
131 (widget-insert value))))
234b16d90545 (describe-text-properties): Sort the output by the size of the values.
Colin Walters <walters@gnu.org>
parents: 45057
diff changeset
132 (widget-insert "\n")))
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 ;;; Describe-Text Commands.
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 (defun describe-text-category (category)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 "Describe a text property category."
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (interactive "S")
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 (when (get-buffer "*Text Category*")
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (kill-buffer "*Text Category*"))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 (save-excursion
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (with-output-to-temp-buffer "*Text Category*"
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (set-buffer "*Text Category*")
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (widget-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
145 (describe-property-list (symbol-plist category))
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (describe-text-mode)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 (goto-char (point-min)))))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ;;;###autoload
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
150 (defun describe-text-properties (pos &optional output-buffer)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
151 "Describe widgets, buttons, overlays and text properties at POS.
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
152 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
153 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
154 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
155 otherwise."
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 (interactive "d")
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (when (eq (current-buffer) (get-buffer "*Text Description*"))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 (error "Can't do self inspection"))
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
159 (if (>= pos (point-max))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
160 (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
161 (if output-buffer
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
162 (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
163 (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
164 (message "This is plain text.")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
165 (let ((buffer (current-buffer)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
166 (save-excursion
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
167 (with-output-to-temp-buffer "*Text Description*"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
168 (set-buffer "*Text Description*")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
169 (setq output-buffer (current-buffer))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
170 (widget-insert "Text content at position " (format "%d" pos) ":\n\n")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
171 (with-current-buffer buffer
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
172 (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
173 (describe-text-mode)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
174 (goto-char (point-min))))))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
175
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
176 (defun describe-text-properties-1 (pos output-buffer)
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (let* ((properties (text-properties-at pos))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (overlays (overlays-at pos))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 overlay
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (wid-field (get-char-property pos 'field))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (wid-button (get-char-property pos 'button))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (wid-doc (get-char-property pos 'widget-doc))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 ;; 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
184 (button (and (fboundp 'button-at) (button-at pos)))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (button-type (and button (button-type button)))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 (button-label (and button (button-label button)))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 (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
188 (with-current-buffer output-buffer
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
189 ;; Widgets
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
190 (when (widgetp widget)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
191 (newline)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
192 (widget-insert (cond (wid-field "This is an editable text area")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
193 (wid-button "This is an active area")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
194 (wid-doc "This is documentation text")))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
195 (widget-insert " of a ")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
196 (describe-text-widget widget)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
197 (widget-insert ".\n\n"))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
198 ;; Buttons
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
199 (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
200 (newline)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
201 (widget-insert "Here is a " (format "%S" button-type)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
202 " button labeled `" button-label "'.\n\n"))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
203 ;; Overlays
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
204 (when overlays
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
205 (newline)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
206 (if (eq (length overlays) 1)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
207 (widget-insert "There is an overlay here:\n")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
208 (widget-insert "There are " (format "%d" (length overlays))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
209 " overlays here:\n"))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
210 (dolist (overlay overlays)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
211 (widget-insert " From " (format "%d" (overlay-start overlay))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
212 " 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
213 (describe-property-list (overlay-properties overlay)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
214 (widget-insert "\n"))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
215 ;; Text properties
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
216 (when properties
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
217 (newline)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
218 (widget-insert "There are text properties here:\n")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
219 (describe-property-list properties)))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
220
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
221 ;;;###autoload
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
222 (defun describe-char (pos)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
223 "Describe the character after POS (interactively, the character after point).
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
224 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
225 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
226 character composition information (if relevant),
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
227 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
228 (interactive "d")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
229 (when (eq (current-buffer) (get-buffer "*Text Description*"))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
230 (error "Can't do self inspection"))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
231 (if (>= pos (point-max))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
232 (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
233 (let* ((char (char-after pos))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
234 (charset (char-charset char))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
235 (buffer (current-buffer))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
236 (composition (find-composition (point) nil nil t))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
237 (composed (if composition (buffer-substring (car composition)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
238 (nth 1 composition))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
239 (multibyte-p enable-multibyte-characters)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
240 item-list max-width)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
241 (if (eq charset 'unknown)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
242 (setq item-list
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
243 `(("character"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
244 ,(format "%s (0%o, %d, 0x%x) -- invalid character code"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
245 (if (< char 256)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
246 (single-key-description char)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
247 (char-to-string char))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
248 char char char))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
249 (setq item-list
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
250 `(("character"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
251 ,(format "%s (0%o, %d, 0x%x)" (if (< char 256)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
252 (single-key-description char)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
253 (char-to-string char))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
254 char char char))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
255 ("charset"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
256 ,(symbol-name charset)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
257 ,(format "(%s)" (charset-description charset)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
258 ("code point"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
259 ,(let ((split (split-char char)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
260 (if (= (charset-dimension charset) 1)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
261 (format "%d" (nth 1 split))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
262 (format "%d %d" (nth 1 split) (nth 2 split)))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
263 ("syntax"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
264 ,(let ((syntax (get-char-property (point) 'syntax-table)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
265 (with-temp-buffer
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
266 (internal-describe-syntax-value
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
267 (if (consp syntax) syntax
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
268 (aref (or syntax (syntax-table)) char)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
269 (buffer-string))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
270 ("category"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
271 ,@(let ((category-set (char-category-set char)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
272 (if (not category-set)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
273 '("-- none --")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
274 (mapcar #'(lambda (x) (format "%c:%s "
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
275 x (category-docstring x)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
276 (category-set-mnemonics category-set)))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
277 ,@(let ((props (aref char-code-property-table char))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
278 ps)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
279 (when props
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
280 (while props
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
281 (push (format "%s:" (pop props)) ps)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
282 (push (format "%s;" (pop props)) ps))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
283 (list (cons "Properties" (nreverse ps)))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
284 ("buffer code"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
285 ,(encoded-string-description
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
286 (string-as-unibyte (char-to-string char)) nil))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
287 ("file code"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
288 ,@(let* ((coding buffer-file-coding-system)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
289 (encoded (encode-coding-char char coding)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
290 (if encoded
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
291 (list (encoded-string-description encoded coding)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
292 (format "(encoded by coding system %S)" coding))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
293 (list "not encodable by coding system"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
294 (symbol-name coding)))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
295 ,@(if (or (memq 'mule-utf-8
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
296 (find-coding-systems-region (point) (1+ (point))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
297 (get-char-property (point) 'untranslated-utf-8))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
298 (let ((uc (or (get-char-property (point)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
299 'untranslated-utf-8)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
300 (encode-char (char-after) 'ucs))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
301 (if uc
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
302 (list (list "Unicode"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
303 (format "%04X" uc))))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
304 ,(if (display-graphic-p (selected-frame))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
305 (list "font" (or (internal-char-font (point))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
306 "-- none --"))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
307 (list "terminal code"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
308 (let* ((coding (terminal-coding-system))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
309 (encoded (encode-coding-char char coding)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
310 (if encoded
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
311 (encoded-string-description encoded coding)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
312 "not encodable")))))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
313 (setq max-width (apply #'max (mapcar #'(lambda (x) (length (car x)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
314 item-list)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
315 (when (get-buffer "*Help*")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
316 (kill-buffer "*Help*"))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
317 (with-output-to-temp-buffer "*Help*"
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (save-excursion
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
319 (set-buffer standard-output)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
320 (set-buffer-multibyte multibyte-p)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
321 (let ((formatter (format "%%%ds:" max-width)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
322 (dolist (elt item-list)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
323 (insert (format formatter (car elt)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
324 (dolist (clm (cdr elt))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
325 (when (>= (+ (current-column)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
326 (or (string-match "\n" clm)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
327 (string-width clm)) 1)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
328 (frame-width))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
329 (insert "\n")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
330 (indent-to (1+ max-width)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
331 (insert " " clm))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
332 (insert "\n")))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
333 (when composition
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
334 (insert "\nComposed with the following character(s) "
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
335 (mapconcat (lambda (x) (format "`%c'" x))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
336 (substring composed 1)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
337 ", ")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
338 " to form `" composed "'")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
339 (if (nth 3 composition)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
340 (insert ".\n")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
341 (insert "\nby the rule ("
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
342 (mapconcat (lambda (x)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
343 (format (if (consp x) "%S" "?%c") x))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
344 (nth 2 composition)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
345 " ")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
346 ").\n"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
347 "See the variable `reference-point-alist' for "
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
348 "the meaning of the rule.\n")))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
349
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
350 (let ((output (current-buffer)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
351 (with-current-buffer buffer
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
352 (describe-text-properties pos output))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
353 (describe-text-mode))))))
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354
45700
a54155344566 (toplevel): Provide `descr-text'.
Colin Walters <walters@gnu.org>
parents: 45697
diff changeset
355 (provide 'descr-text)
a54155344566 (toplevel): Provide `descr-text'.
Colin Walters <walters@gnu.org>
parents: 45697
diff changeset
356
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 ;;; descr-text.el ends here