aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorNick Roberts2005-12-23 01:51:44 +0000
committerNick Roberts2005-12-23 01:51:44 +0000
commit57d79b9944248e2e89085782e426e278144a9491 (patch)
treeaf5358357656e4440250e83d249fe40d59dc3e32 /lisp
parent5552d5a425bfeef0b89fe43b0cda03554ee3bd98 (diff)
downloademacs-57d79b9944248e2e89085782e426e278144a9491.tar.gz
emacs-57d79b9944248e2e89085782e426e278144a9491.zip
Add FSF as maintainer.
(describe-text-mode, describe-text-mode-map) (describe-text-mode-hook, describe-text-done): Delete. Use normal help-mode. (describe-text-widget, describe-text-sexp) (describe-property-list, describe-text-category) (describe-text-properties, describe-text-properties-1) (describe-char): Use help buttons instead of widgets. (describe-char-unicodedata-file): Make URL link in doc string.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/descr-text.el190
1 files changed, 73 insertions, 117 deletions
diff --git a/lisp/descr-text.el b/lisp/descr-text.el
index a75e227d2b0..76d6ae6be09 100644
--- a/lisp/descr-text.el
+++ b/lisp/descr-text.el
@@ -4,6 +4,7 @@
4;; 2005 Free Software Foundation, Inc. 4;; 2005 Free Software Foundation, Inc.
5 5
6;; Author: Boris Goldowsky <boris@gnu.org> 6;; Author: Boris Goldowsky <boris@gnu.org>
7;; Maintainer: FSF
7;; Keywords: faces, i18n, Unicode, multilingual 8;; Keywords: faces, i18n, Unicode, multilingual
8 9
9;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
@@ -31,50 +32,18 @@
31 32
32(eval-when-compile (require 'button) (require 'quail)) 33(eval-when-compile (require 'button) (require 'quail))
33 34
34(defun describe-text-done ()
35 "Delete the current window or bury the current buffer."
36 (interactive)
37 (if (> (count-windows) 1)
38 (delete-window)
39 (bury-buffer)))
40
41(defvar describe-text-mode-map
42 (let ((map (make-sparse-keymap)))
43 (set-keymap-parent map widget-keymap)
44 map)
45 "Keymap for `describe-text-mode'.")
46
47(defcustom describe-text-mode-hook nil
48 "List of hook functions ran by `describe-text-mode'."
49 :type 'hook
50 :group 'facemenu)
51
52(defun describe-text-mode ()
53 "Major mode for buffers created by `describe-char'.
54
55\\{describe-text-mode-map}
56Entry to this mode calls the value of `describe-text-mode-hook'
57if that value is non-nil."
58 (kill-all-local-variables)
59 (setq major-mode 'describe-text-mode
60 mode-name "Describe-Text")
61 (use-local-map describe-text-mode-map)
62 (widget-setup)
63 (add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
64 (run-mode-hooks 'describe-text-mode-hook))
65
66;;; Describe-Text Utilities. 35;;; Describe-Text Utilities.
67 36
68(defun describe-text-widget (widget) 37(defun describe-text-widget (widget)
69 "Insert text to describe WIDGET in the current buffer." 38 "Insert text to describe WIDGET in the current buffer."
70 (widget-create 'link 39 (insert-text-button
71 :notify `(lambda (&rest ignore) 40 (symbol-name (if (symbolp widget) widget (car widget)))
72 (widget-browse ',widget)) 41 'action `(lambda (&rest ignore)
73 (format "%S" (if (symbolp widget) 42 (widget-browse ',widget)))
74 widget 43 (insert " ")
75 (car widget)))) 44 (insert-text-button "(widget)Top"
76 (widget-insert " ") 45 'action (lambda (&rest ignore) (info "(widget)Top"))
77 (widget-create 'info-link :tag "widget" "(widget)Top")) 46 'help-echo "mouse-2, RET: read this Info node"))
78 47
79(defun describe-text-sexp (sexp) 48(defun describe-text-sexp (sexp)
80 "Insert a short description of SEXP in the current buffer." 49 "Insert a short description of SEXP in the current buffer."
@@ -88,20 +57,19 @@ if that value is non-nil."
88 ((> (length pp) (- (window-width) (current-column))) 57 ((> (length pp) (- (window-width) (current-column)))
89 nil) 58 nil)
90 (t t)) 59 (t t))
91 (widget-insert pp) 60 (insert pp)
92 (widget-create 'push-button 61 (insert-text-button
93 :tag "show" 62 "show" 'action `(lambda (&rest ignore)
94 :action (lambda (widget &optional event) 63 (with-output-to-temp-buffer
95 (with-output-to-temp-buffer 64 "*Pp Eval Output*"
96 "*Pp Eval Output*" 65 (princ ',pp)))
97 (princ (widget-get widget :value)))) 66 'help-echo "mouse-2, RET: pretty print value in another buffer"))))
98 pp))))
99 67
100(defun describe-property-list (properties) 68(defun describe-property-list (properties)
101 "Insert a description of PROPERTIES in the current buffer. 69 "Insert a description of PROPERTIES in the current buffer.
102PROPERTIES should be a list of overlay or text properties. 70PROPERTIES should be a list of overlay or text properties.
103The `category', `face' and `font-lock-face' properties are made 71The `category', `face' and `font-lock-face' properties are made
104into widget buttons that call `describe-text-category' or 72into help buttons that call `describe-text-category' or
105`describe-face' when pushed." 73`describe-face' when pushed."
106 ;; Sort the properties by the size of their value. 74 ;; Sort the properties by the size of their value.
107 (dolist (elt (sort (let (ret) 75 (dolist (elt (sort (let (ret)
@@ -112,23 +80,21 @@ into widget buttons that call `describe-text-category' or
112 (prin1-to-string (nth 0 b) t))))) 80 (prin1-to-string (nth 0 b) t)))))
113 (let ((key (nth 0 elt)) 81 (let ((key (nth 0 elt))
114 (value (nth 1 elt))) 82 (value (nth 1 elt)))
115 (widget-insert (propertize (format " %-20s " key) 83 (insert (propertize (format " %-20s " key)
116 'font-lock-face 'italic)) 84 'face 'italic))
117 (cond ((eq key 'category) 85 (cond ((eq key 'category)
118 (widget-create 'link 86 (insert-text-button (symbol-name value)
119 :notify `(lambda (&rest ignore) 87 'action `(lambda (&rest ignore)
120 (describe-text-category ',value)) 88 (describe-text-category ',value))
121 (format "%S" value))) 89 'help-echo
90 "mouse-2, RET: describe this category"))
122 ((memq key '(face font-lock-face mouse-face)) 91 ((memq key '(face font-lock-face mouse-face))
123 (widget-create 'link 92 (insert (concat "`" (format "%S" value) "'")))
124 :notify `(lambda (&rest ignore)
125 (describe-face ',value))
126 (format "%S" value)))
127 ((widgetp value) 93 ((widgetp value)
128 (describe-text-widget value)) 94 (describe-text-widget value))
129 (t 95 (t
130 (describe-text-sexp value)))) 96 (describe-text-sexp value))))
131 (widget-insert "\n"))) 97 (insert "\n")))
132 98
133;;; Describe-Text Commands. 99;;; Describe-Text Commands.
134 100
@@ -138,9 +104,8 @@ into widget buttons that call `describe-text-category' or
138 (save-excursion 104 (save-excursion
139 (with-output-to-temp-buffer "*Help*" 105 (with-output-to-temp-buffer "*Help*"
140 (set-buffer standard-output) 106 (set-buffer standard-output)
141 (widget-insert "Category " (format "%S" category) ":\n\n") 107 (insert "Category " (format "%S" category) ":\n\n")
142 (describe-property-list (symbol-plist category)) 108 (describe-property-list (symbol-plist category))
143 (describe-text-mode)
144 (goto-char (point-min))))) 109 (goto-char (point-min)))))
145 110
146;;;###autoload 111;;;###autoload
@@ -165,10 +130,9 @@ otherwise."
165 (with-output-to-temp-buffer target-buffer 130 (with-output-to-temp-buffer target-buffer
166 (set-buffer standard-output) 131 (set-buffer standard-output)
167 (setq output-buffer (current-buffer)) 132 (setq output-buffer (current-buffer))
168 (widget-insert "Text content at position " (format "%d" pos) ":\n\n") 133 (insert "Text content at position " (format "%d" pos) ":\n\n")
169 (with-current-buffer buffer 134 (with-current-buffer buffer
170 (describe-text-properties-1 pos output-buffer)) 135 (describe-text-properties-1 pos output-buffer))
171 (describe-text-mode)
172 (goto-char (point-min)))))))) 136 (goto-char (point-min))))))))
173 137
174(defun describe-text-properties-1 (pos output-buffer) 138(defun describe-text-properties-1 (pos output-buffer)
@@ -186,33 +150,33 @@ otherwise."
186 ;; Widgets 150 ;; Widgets
187 (when (widgetp widget) 151 (when (widgetp widget)
188 (newline) 152 (newline)
189 (widget-insert (cond (wid-field "This is an editable text area") 153 (insert (cond (wid-field "This is an editable text area")
190 (wid-button "This is an active area") 154 (wid-button "This is an active area")
191 (wid-doc "This is documentation text"))) 155 (wid-doc "This is documentation text")))
192 (widget-insert " of a ") 156 (insert " of a ")
193 (describe-text-widget widget) 157 (describe-text-widget widget)
194 (widget-insert ".\n\n")) 158 (insert ".\n\n"))
195 ;; Buttons 159 ;; Buttons
196 (when (and button (not (widgetp wid-button))) 160 (when (and button (not (widgetp wid-button)))
197 (newline) 161 (newline)
198 (widget-insert "Here is a " (format "%S" button-type) 162 (insert "Here is a " (format "%S" button-type)
199 " button labeled `" button-label "'.\n\n")) 163 " button labeled `" button-label "'.\n\n"))
200 ;; Overlays 164 ;; Overlays
201 (when overlays 165 (when overlays
202 (newline) 166 (newline)
203 (if (eq (length overlays) 1) 167 (if (eq (length overlays) 1)
204 (widget-insert "There is an overlay here:\n") 168 (insert "There is an overlay here:\n")
205 (widget-insert "There are " (format "%d" (length overlays)) 169 (insert "There are " (format "%d" (length overlays))
206 " overlays here:\n")) 170 " overlays here:\n"))
207 (dolist (overlay overlays) 171 (dolist (overlay overlays)
208 (widget-insert " From " (format "%d" (overlay-start overlay)) 172 (insert " From " (format "%d" (overlay-start overlay))
209 " to " (format "%d" (overlay-end overlay)) "\n") 173 " to " (format "%d" (overlay-end overlay)) "\n")
210 (describe-property-list (overlay-properties overlay))) 174 (describe-property-list (overlay-properties overlay)))
211 (widget-insert "\n")) 175 (insert "\n"))
212 ;; Text properties 176 ;; Text properties
213 (when properties 177 (when properties
214 (newline) 178 (newline)
215 (widget-insert "There are text properties here:\n") 179 (insert "There are text properties here:\n")
216 (describe-property-list properties))))) 180 (describe-property-list properties)))))
217 181
218(defcustom describe-char-unicodedata-file nil 182(defcustom describe-char-unicodedata-file nil
@@ -223,8 +187,8 @@ looked up from it. This facility is mostly of use to people doing
223multilingual development. 187multilingual development.
224 188
225This is a fairly large file, not typically present on GNU systems. At 189This is a fairly large file, not typically present on GNU systems. At
226the time of writing it is at 190the time of writing it is at the URL
227<URL:http://www.unicode.org/Public/UNIDATA/UnicodeData.txt>." 191`http://www.unicode.org/Public/UNIDATA/UnicodeData.txt'."
228 :group 'mule 192 :group 'mule
229 :version "22.1" 193 :version "22.1"
230 :type '(choice (const :tag "None" nil) 194 :type '(choice (const :tag "None" nil)
@@ -488,27 +452,28 @@ as well as widgets, buttons, overlays, and text properties."
488 (format ", U+%04X" unicode) 452 (format ", U+%04X" unicode)
489 ""))) 453 "")))
490 ("charset" 454 ("charset"
491 ,`(widget-create 'link 455 ,`(insert-text-button
492 :notify (lambda (&rest ignore) 456 (symbol-name charset)
493 (describe-character-set ',charset)) 457 'action `(lambda (&rest ignore)
494 ,(symbol-name charset)) 458 (describe-character-set ',charset))
459 'help-echo
460 "mouse-2, RET: describe this character set")
495 ,(format "(%s)" (charset-description charset))) 461 ,(format "(%s)" (charset-description charset)))
496 ("code point" 462 ("code point"
497 ,(let ((split (split-char char))) 463 ,(let ((split (split-char char)))
498 `(widget-create 464 `(insert-text-button ,(if (= (charset-dimension charset) 1)
499 'link 465 (format "%d" (nth 1 split))
500 :notify (lambda (&rest ignore) 466 (format "%d %d" (nth 1 split)
501 (list-charset-chars ',charset) 467 (nth 2 split)))
502 (with-selected-window 468 'action (lambda (&rest ignore)
503 (get-buffer-window "*Character List*" 0) 469 (list-charset-chars ',charset)
504 (goto-char (point-min)) 470 (with-selected-window
471 (get-buffer-window "*Character List*" 0)
472 (goto-char (point-min))
505 (forward-line 2) ;Skip the header. 473 (forward-line 2) ;Skip the header.
506 (let ((case-fold-search nil)) 474 (let ((case-fold-search nil))
507 (search-forward ,(char-to-string char) 475 (search-forward ,(char-to-string char)
508 nil t)))) 476 nil t)))))))
509 ,(if (= (charset-dimension charset) 1)
510 (format "%d" (nth 1 split))
511 (format "%d %d" (nth 1 split) (nth 2 split))))))
512 ("syntax" 477 ("syntax"
513 ,(let ((syntax (syntax-after pos))) 478 ,(let ((syntax (syntax-after pos)))
514 (with-temp-buffer 479 (with-temp-buffer
@@ -537,12 +502,11 @@ as well as widgets, buttons, overlays, and text properties."
537 (mapconcat #'(lambda (x) (concat "\"" x "\"")) 502 (mapconcat #'(lambda (x) (concat "\"" x "\""))
538 key-list " or ") 503 key-list " or ")
539 "with" 504 "with"
540 `(widget-create 505 `(insert-text-button
541 'link 506 (symbol-name current-input-method)
542 :notify (lambda (&rest ignore) 507 'action (lambda (&rest ignore)
543 (describe-input-method 508 (describe-input-method
544 ',current-input-method)) 509 ',current-input-method)))))))
545 ,(format "%s" current-input-method))))))
546 ("buffer code" 510 ("buffer code"
547 ,(encoded-string-description 511 ,(encoded-string-description
548 (string-as-unibyte (char-to-string char)) nil)) 512 (string-as-unibyte (char-to-string char)) nil))
@@ -611,11 +575,8 @@ as well as widgets, buttons, overlays, and text properties."
611 ((and (< char 32) (not (memq char '(9 10)))) 575 ((and (< char 32) (not (memq char '(9 10))))
612 'escape-glyph))))) 576 'escape-glyph)))))
613 (if face (list (list "hardcoded face" 577 (if face (list (list "hardcoded face"
614 `(widget-create 578 '(insert
615 'link 579 (concat "`" (symbol-name face) "'"))))))
616 :notify (lambda (&rest ignore)
617 (describe-face ',face))
618 ,(format "%s" face))))))
619 ,@(let ((unicodedata (and unicode 580 ,@(let ((unicodedata (and unicode
620 (describe-char-unicode-data unicode)))) 581 (describe-char-unicode-data unicode))))
621 (if unicodedata 582 (if unicodedata
@@ -623,17 +584,16 @@ as well as widgets, buttons, overlays, and text properties."
623 (setq max-width (apply #'max (mapcar #'(lambda (x) 584 (setq max-width (apply #'max (mapcar #'(lambda (x)
624 (if (cadr x) (length (car x)) 0)) 585 (if (cadr x) (length (car x)) 0))
625 item-list))) 586 item-list)))
626 (with-output-to-temp-buffer "*Help*" 587 (help-setup-xref nil (interactive-p))
588 (with-output-to-temp-buffer (help-buffer)
627 (with-current-buffer standard-output 589 (with-current-buffer standard-output
628 (let ((help-xref-following t))
629 (help-setup-xref nil nil))
630 (set-buffer-multibyte multibyte-p) 590 (set-buffer-multibyte multibyte-p)
631 (let ((formatter (format "%%%ds:" max-width))) 591 (let ((formatter (format "%%%ds:" max-width)))
632 (dolist (elt item-list) 592 (dolist (elt item-list)
633 (when (cadr elt) 593 (when (cadr elt)
634 (insert (format formatter (car elt))) 594 (insert (format formatter (car elt)))
635 (dolist (clm (cdr elt)) 595 (dolist (clm (cdr elt))
636 (if (eq (car-safe clm) 'widget-create) 596 (if (eq (car-safe clm) 'insert-text-button)
637 (progn (insert " ") (eval clm)) 597 (progn (insert " ") (eval clm))
638 (when (>= (+ (current-column) 598 (when (>= (+ (current-column)
639 (or (string-match "\n" clm) 599 (or (string-match "\n" clm)
@@ -673,17 +633,15 @@ as well as widgets, buttons, overlays, and text properties."
673 "\n") 633 "\n")
674 (when (> (car (aref disp-vector i)) #x7ffff) 634 (when (> (car (aref disp-vector i)) #x7ffff)
675 (let* ((face-id (lsh (car (aref disp-vector i)) -19)) 635 (let* ((face-id (lsh (car (aref disp-vector i)) -19))
676 (face (car (delq nil (mapcar (lambda (face) 636 (face (car (delq nil (mapcar
677 (and (eq (face-id face) 637 (lambda (face)
678 face-id) face)) 638 (and (eq (face-id face)
679 (face-list)))))) 639 face-id) face))
640 (face-list))))))
680 (when face 641 (when face
681 (insert (propertize " " 'display '(space :align-to 5)) 642 (insert (propertize " " 'display '(space :align-to 5))
682 "face: ") 643 "face: ")
683 (widget-create 'link 644 (insert (concat "`" (symbol-name face) "'"))
684 :notify `(lambda (&rest ignore)
685 (describe-face ',face))
686 (format "%S" face))
687 (insert "\n")))))) 645 (insert "\n"))))))
688 (insert "these terminal codes:\n") 646 (insert "these terminal codes:\n")
689 (dotimes (i (length disp-vector)) 647 (dotimes (i (length disp-vector))
@@ -729,9 +687,7 @@ as well as widgets, buttons, overlays, and text properties."
729 "the meaning of the rule.\n")) 687 "the meaning of the rule.\n"))
730 688
731 (if text-props-desc (insert text-props-desc)) 689 (if text-props-desc (insert text-props-desc))
732 (describe-text-mode)
733 (toggle-read-only 1) 690 (toggle-read-only 1)
734 (help-make-xrefs (current-buffer))
735 (print-help-return-message))))) 691 (print-help-return-message)))))
736 692
737(defalias 'describe-char-after 'describe-char) 693(defalias 'describe-char-after 'describe-char)