annotate lisp/descr-text.el @ 47820:ac369f2f8f6a

#
author André Spiegel <spiegel@gnu.org>
date Thu, 10 Oct 2002 08:49:31 +0000
parents 7d00d911e8b9
children e84990b6ae01
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 (save-excursion
47601
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
140 (with-output-to-temp-buffer "*Help*"
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
141 (set-buffer standard-output)
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (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
143 (describe-property-list (symbol-plist category))
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (describe-text-mode)
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 (goto-char (point-min)))))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 ;;;###autoload
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
148 (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
149 "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
150 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
151 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
152 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
153 otherwise."
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 (interactive "d")
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
155 (if (>= pos (point-max))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
156 (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
157 (if output-buffer
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
158 (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
159 (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
160 (message "This is plain text.")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
161 (let ((buffer (current-buffer)))
47601
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
162 (when (eq buffer (get-buffer "*Help*"))
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
163 (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
164 (save-excursion
47601
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
165 (with-output-to-temp-buffer "*Help*"
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
166 (set-buffer standard-output)
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
167 (setq output-buffer (current-buffer))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
168 (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
169 (with-current-buffer buffer
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
170 (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
171 (describe-text-mode)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
172 (goto-char (point-min))))))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
173
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
174 (defun describe-text-properties-1 (pos output-buffer)
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 (let* ((properties (text-properties-at pos))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (overlays (overlays-at pos))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 overlay
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (wid-field (get-char-property pos 'field))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (wid-button (get-char-property pos 'button))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (wid-doc (get-char-property pos 'widget-doc))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 ;; 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
182 (button (and (fboundp 'button-at) (button-at pos)))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 (button-type (and button (button-type button)))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 (button-label (and button (button-label button)))
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (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
186 (with-current-buffer output-buffer
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
187 ;; Widgets
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
188 (when (widgetp widget)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
189 (newline)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
190 (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
191 (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
192 (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
193 (widget-insert " of a ")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
194 (describe-text-widget widget)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
195 (widget-insert ".\n\n"))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
196 ;; Buttons
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
197 (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
198 (newline)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
199 (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
200 " 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
201 ;; Overlays
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
202 (when overlays
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
203 (newline)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
204 (if (eq (length overlays) 1)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
205 (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
206 (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
207 " overlays here:\n"))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
208 (dolist (overlay overlays)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
209 (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
210 " 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
211 (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
212 (widget-insert "\n"))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
213 ;; Text properties
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
214 (when properties
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
215 (newline)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
216 (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
217 (describe-property-list properties)))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
218
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
219 ;;;###autoload
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
220 (defun describe-char (pos)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
221 "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
222 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
223 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
224 character composition information (if relevant),
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
225 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
226 (interactive "d")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
227 (if (>= pos (point-max))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
228 (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
229 (let* ((char (char-after pos))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
230 (charset (char-charset char))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
231 (buffer (current-buffer))
47601
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
232 (composition (find-composition pos nil nil t))
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
233 (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
234 (nth 1 composition))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
235 (multibyte-p enable-multibyte-characters)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
236 item-list max-width)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
237 (if (eq charset 'unknown)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
238 (setq item-list
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
239 `(("character"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
240 ,(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
241 (if (< char 256)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
242 (single-key-description char)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
243 (char-to-string char))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
244 char char char))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
245 (setq item-list
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
246 `(("character"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
247 ,(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
248 (single-key-description char)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
249 (char-to-string char))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
250 char char char))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
251 ("charset"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
252 ,(symbol-name charset)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
253 ,(format "(%s)" (charset-description charset)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
254 ("code point"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
255 ,(let ((split (split-char char)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
256 (if (= (charset-dimension charset) 1)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
257 (format "%d" (nth 1 split))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
258 (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
259 ("syntax"
47601
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
260 ,(let ((syntax (syntax-after pos)))
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
261 (with-temp-buffer
47601
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
262 (internal-describe-syntax-value syntax)
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
263 (buffer-string))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
264 ("category"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
265 ,@(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
266 (if (not category-set)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
267 '("-- none --")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
268 (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
269 x (category-docstring x)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
270 (category-set-mnemonics category-set)))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
271 ,@(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
272 ps)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
273 (when props
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
274 (while props
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
275 (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
276 (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
277 (list (cons "Properties" (nreverse ps)))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
278 ("buffer code"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
279 ,(encoded-string-description
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
280 (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
281 ("file code"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
282 ,@(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
283 (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
284 (if encoded
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
285 (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
286 (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
287 (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
288 (symbol-name coding)))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
289 ,@(if (or (memq 'mule-utf-8
47601
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
290 (find-coding-systems-region pos (1+ pos)))
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
291 (get-char-property pos 'untranslated-utf-8))
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
292 (let ((uc (or (get-char-property pos 'untranslated-utf-8)
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
293 (encode-char char 'ucs))))
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
294 (if uc
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
295 (list (list "Unicode"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
296 (format "%04X" uc))))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
297 ,(if (display-graphic-p (selected-frame))
47601
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
298 (list "font" (or (internal-char-font pos)
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
299 "-- none --"))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
300 (list "terminal code"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
301 (let* ((coding (terminal-coding-system))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
302 (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
303 (if encoded
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
304 (encoded-string-description encoded coding)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
305 "not encodable")))))))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
306 (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
307 item-list)))
47601
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
308 (when (eq (current-buffer) (get-buffer "*Help*"))
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
309 (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
310 (with-output-to-temp-buffer "*Help*"
47601
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
311 (with-current-buffer standard-output
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
312 (set-buffer-multibyte multibyte-p)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
313 (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
314 (dolist (elt item-list)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
315 (insert (format formatter (car elt)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
316 (dolist (clm (cdr elt))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
317 (when (>= (+ (current-column)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
318 (or (string-match "\n" clm)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
319 (string-width clm)) 1)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
320 (frame-width))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
321 (insert "\n")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
322 (indent-to (1+ max-width)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
323 (insert " " clm))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
324 (insert "\n")))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
325 (when composition
47601
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
326 (insert "\nComposed with the "
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
327 (cond
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
328 ((eq pos (car composition)) "following ")
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
329 ((eq (1+ pos) (cadr composition)) "preceding ")
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
330 (t ""))
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
331 "character(s) `"
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
332 (cond
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
333 ((eq pos (car composition)) (substring composed 1))
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
334 ((eq (1+ pos) (cadr composition)) (substring composed 0 -1))
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
335 (t (concat (substring composed 0 (- pos (car composition)))
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
336 "' and `"
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
337 (substring composed (- (1+ pos) (car composition))))))
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
338
7d00d911e8b9 (describe-text-category): Use *Help*. Don't kill-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47379
diff changeset
339 "' to form `" composed "'")
45868
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
340 (if (nth 3 composition)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
341 (insert ".\n")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
342 (insert "\nby the rule ("
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
343 (mapconcat (lambda (x)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
344 (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
345 (nth 2 composition)
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
346 " ")
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
347 ").\n"
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
348 "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
349 "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
350
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
351 (let ((output (current-buffer)))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
352 (with-current-buffer buffer
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
353 (describe-text-properties pos output))
97041c98624e (describe-char): Moved from mule-diag.el, renamed
Richard M. Stallman <rms@gnu.org>
parents: 45700
diff changeset
354 (describe-text-mode))))))
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355
45700
a54155344566 (toplevel): Provide `descr-text'.
Colin Walters <walters@gnu.org>
parents: 45697
diff changeset
356 (provide 'descr-text)
a54155344566 (toplevel): Provide `descr-text'.
Colin Walters <walters@gnu.org>
parents: 45697
diff changeset
357
45022
4359b383982c *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 ;;; descr-text.el ends here