Changeset 4018 for vendor/emacs-CVS_HEAD/lisp/descr-text.el
- Timestamp:
- 01/28/06 09:46:44 (3 years ago)
- Files:
-
- vendor/emacs-CVS_HEAD/lisp/descr-text.el (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
vendor/emacs-CVS_HEAD/lisp/descr-text.el
r3988 r4018 5 5 6 6 ;; Author: Boris Goldowsky <boris@gnu.org> 7 ;; Maintainer: FSF 7 8 ;; Keywords: faces, i18n, Unicode, multilingual 8 9 … … 30 31 ;;; Code: 31 32 32 (eval-when-compile (require 'button) (require 'quail)) 33 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} 56 Entry to this mode calls the value of `describe-text-mode-hook' 57 if 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)) 33 (eval-when-compile (require 'quail)) 34 (require 'help-fns) 65 35 66 36 ;;; Describe-Text Utilities. … … 68 38 (defun describe-text-widget (widget) 69 39 "Insert text to describe WIDGET in the current buffer." 70 ( widget-create 'link71 :notify `(lambda (&rest ignore)72 (widget-browse ',widget))73 (format "%S" (if (symbolp widget)74 widget 75 (car widget))))76 ( widget-insert " ")77 (widget-create 'info-link :tag "widget" "(widget)Top"))40 (insert-text-button 41 (symbol-name (if (symbolp widget) widget (car widget))) 42 'action `(lambda (&rest ignore) 43 (widget-browse ',widget)) 44 'help-echo "mouse-2, RET: browse this widget") 45 (insert " ") 46 (insert-text-button 47 "(widget)Top" 'type 'help-info 'help-args '("(widget)Top"))) 78 48 79 49 (defun describe-text-sexp (sexp) … … 89 59 nil) 90 60 (t t)) 91 (widget-insert pp) 92 (widget-create 'push-button 93 :tag "show" 94 :action (lambda (widget &optional event) 95 (with-output-to-temp-buffer 96 "*Pp Eval Output*" 97 (princ (widget-get widget :value)))) 98 pp)))) 61 (insert pp) 62 (insert-text-button 63 "[Show]" 'action `(lambda (&rest ignore) 64 (with-output-to-temp-buffer 65 "*Pp Eval Output*" 66 (princ ',pp))) 67 'help-echo "mouse-2, RET: pretty print value in another buffer")))) 99 68 100 69 (defun describe-property-list (properties) … … 102 71 PROPERTIES should be a list of overlay or text properties. 103 72 The `category', `face' and `font-lock-face' properties are made 104 into widgetbuttons that call `describe-text-category' or73 into help buttons that call `describe-text-category' or 105 74 `describe-face' when pushed." 106 75 ;; Sort the properties by the size of their value. … … 113 82 (let ((key (nth 0 elt)) 114 83 (value (nth 1 elt))) 115 ( widget-insert (propertize (format " %-20s " key)116 'font-lock-face 'italic))84 (insert (propertize (format " %-20s " key) 85 'face 'help-argument-name)) 117 86 (cond ((eq key 'category) 118 (widget-create 'link 119 :notify `(lambda (&rest ignore) 120 (describe-text-category ',value)) 121 (format "%S" value))) 87 (insert-text-button 88 (symbol-name value) 89 'action `(lambda (&rest ignore) 90 (describe-text-category ',value)) 91 'help-echo "mouse-2, RET: describe this category")) 122 92 ((memq key '(face font-lock-face mouse-face)) 123 (widget-create 'link 124 :notify `(lambda (&rest ignore) 125 (describe-face ',value)) 126 (format "%S" value))) 93 (insert-text-button 94 (format "%S" value) 95 'type 'help-face 'help-args (list value))) 127 96 ((widgetp value) 128 97 (describe-text-widget value)) 129 98 (t 130 99 (describe-text-sexp value)))) 131 ( widget-insert "\n")))100 (insert "\n"))) 132 101 133 102 ;;; Describe-Text Commands. … … 135 104 (defun describe-text-category (category) 136 105 "Describe a text property category." 137 (interactive "S") 106 (interactive "SCategory: ") 107 (help-setup-xref (list #'describe-text-category category) (interactive-p)) 138 108 (save-excursion 139 109 (with-output-to-temp-buffer "*Help*" 140 110 (set-buffer standard-output) 141 ( widget-insert "Category " (format "%S" category) ":\n\n")111 (insert "Category " (format "%S" category) ":\n\n") 142 112 (describe-property-list (symbol-plist category)) 143 (describe-text-mode)144 113 (goto-char (point-min))))) 145 114 … … 161 130 (target-buffer "*Help*")) 162 131 (when (eq buffer (get-buffer target-buffer)) 163 (setq target-buffer "*Help -2*"))132 (setq target-buffer "*Help*<2>")) 164 133 (save-excursion 165 134 (with-output-to-temp-buffer target-buffer 166 135 (set-buffer standard-output) 167 136 (setq output-buffer (current-buffer)) 168 ( widget-insert "Text content at position " (format "%d" pos) ":\n\n")137 (insert "Text content at position " (format "%d" pos) ":\n\n") 169 138 (with-current-buffer buffer 170 139 (describe-text-properties-1 pos output-buffer)) 171 (describe-text-mode)172 140 (goto-char (point-min)))))))) 173 141 … … 187 155 (when (widgetp widget) 188 156 (newline) 189 ( widget-insert (cond (wid-field "This is an editable text area")190 (wid-button "This is an active area")191 (wid-doc "This is documentation text")))192 ( widget-insert " of a ")157 (insert (cond (wid-field "This is an editable text area") 158 (wid-button "This is an active area") 159 (wid-doc "This is documentation text"))) 160 (insert " of a ") 193 161 (describe-text-widget widget) 194 ( widget-insert ".\n\n"))162 (insert ".\n\n")) 195 163 ;; Buttons 196 164 (when (and button (not (widgetp wid-button))) 197 165 (newline) 198 ( widget-insert "Here is a" (format "%S" button-type)199 "button labeled `" button-label "'.\n\n"))166 (insert "Here is a `" (format "%S" button-type) 167 "' button labeled `" button-label "'.\n\n")) 200 168 ;; Overlays 201 169 (when overlays 202 170 (newline) 203 171 (if (eq (length overlays) 1) 204 ( widget-insert "There is an overlay here:\n")205 ( widget-insert "There are " (format "%d" (length overlays))172 (insert "There is an overlay here:\n") 173 (insert "There are " (format "%d" (length overlays)) 206 174 " overlays here:\n")) 207 175 (dolist (overlay overlays) 208 ( widget-insert " From " (format "%d" (overlay-start overlay))176 (insert " From " (format "%d" (overlay-start overlay)) 209 177 " to " (format "%d" (overlay-end overlay)) "\n") 210 178 (describe-property-list (overlay-properties overlay))) 211 ( widget-insert "\n"))179 (insert "\n")) 212 180 ;; Text properties 213 181 (when properties 214 182 (newline) 215 ( widget-insert "There are text properties here:\n")183 (insert "There are text properties here:\n") 216 184 (describe-property-list properties))))) 217 185 … … 224 192 225 193 This is a fairly large file, not typically present on GNU systems. At 226 the time of writing it is at 227 <URL:http://www.unicode.org/Public/UNIDATA/UnicodeData.txt>."194 the time of writing it is at the URL 195 `http://www.unicode.org/Public/UNIDATA/UnicodeData.txt'." 228 196 :group 'mule 229 197 :version "22.1" … … 465 433 (string-to-multibyte 466 434 (char-to-string char))))) 435 (text-props-desc 436 (let ((tmp-buf (generate-new-buffer " *text-props*"))) 437 (unwind-protect 438 (progn 439 (describe-text-properties pos tmp-buf) 440 (with-current-buffer tmp-buf (buffer-string))) 441 (kill-buffer tmp-buf)))) 467 442 item-list max-width unicode) 468 443 … … 474 449 (setq item-list 475 450 `(("character" 476 ,(format "%s (%d, #o%o, #x%x%s)"477 (apply 'propertize char-description478 (text-properties-at pos))479 char char char480 (if unicode481 (format ", U+%04X" unicode)482 "")))451 ,(format "%s (%d, #o%o, #x%x%s)" 452 (apply 'propertize char-description 453 (text-properties-at pos)) 454 char char char 455 (if unicode 456 (format ", U+%04X" unicode) 457 ""))) 483 458 ("charset" 484 ,`(widget-create 'link 485 :notify (lambda (&rest ignore) 486 (describe-character-set ',charset)) 487 ,(symbol-name charset)) 459 ,`(insert-text-button 460 ,(symbol-name charset) 461 'type 'help-character-set 'help-args '(,charset)) 488 462 ,(format "(%s)" (charset-description charset))) 489 463 ("code point" 490 464 ,(let ((split (split-char char))) 491 `(widget-create 492 'link 493 :notify (lambda (&rest ignore) 465 `(insert-text-button 466 ,(if (= (charset-dimension charset) 1) 467 (format "#x%02X" (nth 1 split)) 468 (format "#x%02X #x%02X" (nth 1 split) 469 (nth 2 split))) 470 'action (lambda (&rest ignore) 494 471 (list-charset-chars ',charset) 495 472 (with-selected-window 496 473 (get-buffer-window "*Character List*" 0) 497 474 (goto-char (point-min)) 498 (forward-line 2) ;Skip the header. 499 (let ((case-fold-search nil)) 500 (search-forward ,(char-to-string char) 501 nil t)))) 502 ,(if (= (charset-dimension charset) 1) 503 (format "%d" (nth 1 split)) 504 (format "%d %d" (nth 1 split) (nth 2 split)))))) 475 (forward-line 2) ;Skip the header. 476 (let ((case-fold-search nil)) 477 (search-forward ,(char-to-string char) 478 nil t)))) 479 'help-echo 480 "mouse-2, RET: show this character in its character set"))) 505 481 ("syntax" 506 482 ,(let ((syntax (syntax-after pos))) … … 531 507 key-list " or ") 532 508 "with" 533 `(widget-create 534 'link 535 :notify (lambda (&rest ignore) 536 (describe-input-method 537 ',current-input-method)) 538 ,(format "%s" current-input-method)))))) 509 `(insert-text-button 510 ,current-input-method 511 'type 'help-input-method 512 'help-args '(,current-input-method)))))) 539 513 ("buffer code" 540 514 ,(encoded-string-description … … 605 579 'escape-glyph))))) 606 580 (if face (list (list "hardcoded face" 607 `(widget-create 608 'link 609 :notify (lambda (&rest ignore) 610 (describe-face ',face)) 611 ,(format "%s" face)))))) 581 `(insert-text-button 582 ,(symbol-name face) 583 'type 'help-face 'help-args '(,face)))))) 612 584 ,@(let ((unicodedata (and unicode 613 585 (describe-char-unicode-data unicode)))) … … 617 589 (if (cadr x) (length (car x)) 0)) 618 590 item-list))) 619 (with-output-to-temp-buffer "*Help*" 591 (help-setup-xref nil (interactive-p)) 592 (with-output-to-temp-buffer (help-buffer) 620 593 (with-current-buffer standard-output 621 594 (set-buffer-multibyte multibyte-p) … … 625 598 (insert (format formatter (car elt))) 626 599 (dolist (clm (cdr elt)) 627 (if (eq (car-safe clm) ' widget-create)600 (if (eq (car-safe clm) 'insert-text-button) 628 601 (progn (insert " ") (eval clm)) 629 602 (when (>= (+ (current-column) … … 637 610 (insert "\n")))) 638 611 639 (save-excursion 640 (goto-char (point-min)) 641 (re-search-forward "character:[ \t\n]+") 642 (setq pos (point))) 643 (let ((end (+ pos (length char-description)))) 644 (if overlays 612 (when overlays 613 (save-excursion 614 (goto-char (point-min)) 615 (re-search-forward "character:[ \t\n]+") 616 (let* ((end (+ (point) (length char-description)))) 645 617 (mapc #'(lambda (props) 646 (let ((o (make-overlay posend)))618 (let ((o (make-overlay (point) end))) 647 619 (while props 648 620 (overlay-put o (car props) (nth 1 props)) 649 621 (setq props (cddr props))))) 650 overlays))) 622 overlays)))) 651 623 652 624 (when disp-vector … … 666 638 (when (> (car (aref disp-vector i)) #x7ffff) 667 639 (let* ((face-id (lsh (car (aref disp-vector i)) -19)) 668 (face (car (delq nil (mapcar (lambda (face) 669 (and (eq (face-id face) 670 face-id) face)) 671 (face-list)))))) 640 (face (car (delq nil (mapcar 641 (lambda (face) 642 (and (eq (face-id face) 643 face-id) face)) 644 (face-list)))))) 672 645 (when face 673 646 (insert (propertize " " 'display '(space :align-to 5)) 674 647 "face: ") 675 (widget-create 'link 676 :notify `(lambda (&rest ignore) 677 (describe-face ',face)) 678 (format "%S" face)) 648 (insert (concat "`" (symbol-name face) "'")) 679 649 (insert "\n")))))) 680 650 (insert "these terminal codes:\n") … … 721 691 "the meaning of the rule.\n")) 722 692 723 (describe-text-properties pos (current-buffer)) 724 (describe-text-mode))))) 693 (if text-props-desc (insert text-props-desc)) 694 (setq help-xref-stack-item (list 'help-insert-string (buffer-string))) 695 (toggle-read-only 1) 696 (print-help-return-message))))) 725 697 726 698 (defalias 'describe-char-after 'describe-char)
